mp-computed

1.1.2 • Public • Published

像 Vuejs 一样在小程序中使用计算属性

how to use

install mp-computed

npm i mp-computed

use in your page.js

in your page's js file

const { createReactive } = require('mp-computed')

Page({
  onLoad() {
    createReactive.call(this)
  },
  data: {
    name: 'stranger'
  },
  computed: {
    sayHi() {
      return `hello! ${this.data.name}`
    }
  },
  changeName() {
    this.setData({ name: 'nicong622' })
  }
})

in your page's wxml file

<view>{{sayHi}}</view>

<button bindtap="changeName">change name</button>

Dependents (1)

Package Sidebar

Install

npm i mp-computed

Weekly Downloads

1

Version

1.1.2

License

MIT

Unpacked Size

11.4 kB

Total Files

10

Last publish

Collaborators

  • nicong622