npm.io
1.0.2 • Published 7 years ago

wxapp-computed

Licence
ISC
Version
1.0.2
Deps
0
Size
3 kB
Vulns
0
Weekly
0
Stars
20

wxapp-computed

在小程序中使计算值(computed),易用、轻量、无依赖、无侵入。

Installation

npm install wxapp-computed

Example

import computed from 'wxapp-computed'

Page(
  computed({
    data: {
      name: 'Messi',
      get uppercaseName() {
        return this.name.toUpperCase()
      },
      get reversedName() {
        return this.uppercaseName.split('').reverse().join('')
      }
    },
    onLoad() {
      // this.setData({ name: 'Ronaldo' })
    }
    // ...
  })
)
<view>
  {{name}} / {{uppercaseName}} / {{reversedName}}
</view>

API

computed(page:Object)

传入 page 页面对象.

License

ISC

Keywords