做网店哪些网站比较好,政务公开网站建设管理,中国房地产100强名单,成都 在线 网站建设安装依赖
npm init -y // 如果你的小程序根目录不是全英文#xff0c;那么输入npm init#xff0c;然后输入任意一个英文名称#xff0c;一直回车即可
npm install --production
npm install --save miniprogram-computed构建npm
点击微信开发者工具上方工具栏的 工具 -那么输入npm init然后输入任意一个英文名称一直回车即可
npm install --production
npm install --save miniprogram-computed构建npm
点击微信开发者工具上方工具栏的 工具 - 构建npm - 构建完成点击确定即可
使用computed
1.在需要使用的页面或组件中引用
const computedBehavior require(miniprogram-computed).behavior
// import {
// behavior as computedBehavior
// } from miniprogram-computed2.在pages中加入
behaviors: [computedBehavior],3.使用方法
Page({behaviors: [computedBehavior],data: {homeTeam: {score: 0},seconds: 0,},watch: {homeTeam.score: function (val) {console.log(val---, val);}},computed: {formatTime(data) {// 注意 computed 函数中不能访问 this 只有 data 对象可供访问// 这个函数的返回值会被设置到 this.data.sum 字段中const minutes Math.floor(data.seconds / 60)return minutes}}})4.wxml中使用计算属性
div classtimer{{ formatTime }}/div