Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
business-assistant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b45c23a0
authored
Nov 07, 2022
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增功能
1 parent
515d0de8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
23 deletions
READ.md
packagesList/mineDetail/pages/customerManagement.js
READ.md
View file @
b45c23a
## 正式版appid wx2c28337db96364d2
## 正式版appid wx2c28337db96364d2
## 体验版appid wx24ebae5768e74138
## 体验版appid wx24ebae5768e74138
# computed和watch方法使用
#### computed和watch方法使用
先导入并混合
```
// 注意: computed 函数中不能访问 this ,只有 data 对象可供访问
```
```
js
// 导入方法
import
{
behavior
as
computedBehavior
}
from
'~/utils/lib/miniprogram-computed'
// 混入
behaviors
:
[
computedBehavior
],
// 使用
computed
:
{
test
(
data
)
{
return
data
.
bgUrl
+
data
.
test
}
},
// 默认已深度监听
watch
:
{
'test, pages'
:
function
(
a
,
b
)
{
console
.
log
(
a
)
// this.setData({
// sum: a + b,
// })
}
},
```
packagesList/mineDetail/pages/customerManagement.js
View file @
b45c23a
...
@@ -3,7 +3,7 @@ import mineApi from '~/api/mineApi/index'
...
@@ -3,7 +3,7 @@ import mineApi from '~/api/mineApi/index'
// import USERAPI from '~/api/usersApi/index'
// import USERAPI from '~/api/usersApi/index'
import
{
IMG_URL
}
from
'~/utils/constantData'
import
{
IMG_URL
}
from
'~/utils/constantData'
// console.log(IMG_URL)
// console.log(IMG_URL)
import
{
behavior
as
computedBehavior
}
from
'~/utils/lib/miniprogram-computed'
//
import { behavior as computedBehavior } from '~/utils/lib/miniprogram-computed'
const
listObj
=
Object
.
freeze
([
const
listObj
=
Object
.
freeze
([
{
{
...
@@ -62,7 +62,7 @@ const listObj = Object.freeze([
...
@@ -62,7 +62,7 @@ const listObj = Object.freeze([
}
}
])
])
Component
({
Component
({
behaviors
:
[
computedBehavior
],
//
behaviors: [computedBehavior],
options
:
{
options
:
{
addGlobalClass
:
true
addGlobalClass
:
true
},
},
...
@@ -97,31 +97,31 @@ Component({
...
@@ -97,31 +97,31 @@ Component({
this
.
getMerchantCustomInfoList
()
this
.
getMerchantCustomInfoList
()
this
.
testFn
()
this
.
testFn
()
},
},
computed
:
{
//
computed: {
test
(
data
)
{
//
test(data) {
return
data
.
bgUrl
+
data
.
pageNum
//
return data.bgUrl + data.pageNum
}
//
}
},
//
},
watch
:
{
//
watch: {
'testData
, pages'
:
function
(
a
,
b
)
{
// 'test
, pages': function (a, b) {
console
.
log
(
a
)
//
console.log(a)
// this.setData({
//
// this.setData({
// sum: a + b,
//
// sum: a + b,
// })
//
// })
}
//
}
},
//
},
/**
/**
* 组件的方法列表
* 组件的方法列表
*/
*/
methods
:
{
methods
:
{
testFn
()
{
//
testFn() {
// let {}
//
// let {}
let
name
=
`testData[0].a`
//
let name = `testData[0].a`
this
.
setData
({
//
this.setData({
[
name
]:
2
//
[name]: 2
})
//
})
},
//
},
restPageNum
()
{
restPageNum
()
{
console
.
log
(
'restPageNum'
)
console
.
log
(
'restPageNum'
)
this
.
setData
({
this
.
setData
({
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment