代码拉取完成,页面将自动刷新
Immutable data for Tina.js
# ensure immutable is installed
npm i -save immutable@^4.0.0-rc.9
# install tina-immutable
npm i --save @tinajs/tina-immutable
// app.js
import Tina from '@tinajs/tina'
import ImmutablePlugin from '@tinajs/tina-immutable'
Tina.use(ImmutablePlugin)
// pages/some-page.js
import { Page } from '@tinajs/tina'
import { fromJS, Map } from 'immutable'
Page.define({
data: {
// The default values of data could be Immutable-Objects,
books: fromJS([
{ id: 1, title: 'Black Beauty' },
{ id: 2, title: '20,000 Leagues Under the Sea' },
]),
// or just any plain types.
messages: [{
{ id: 1, content: 'I thought you might sway closer each day' },
{ id: 2, content: 'All I wish I could say but you shy away.' },
}],
isLoading: false,
title: 'Favorites',
},
methods: {
more () {
let messages = this.data.get('messages')
this.setData({
messages: this.data.get('messages').push(new Map({
id: 3,
content: 'Our eyes engage but I can\'t see who\'s nearer.',
}))
})
},
},
})
// components/like.js
import { Component } from '@tinajs/tina'
import { fromJS, Map } from 'immutable'
Component.define({
properties: {
// Limited by the offical Mina framkework, properties only accepts [plain types](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/custom-component/component.html).
// However, our tina-immutable plugin will transform the values of all properties to Immutable, before they are merged into ``this.data``.
item: Object,
},
data: {
like: true,
},
methods: {
toggle () {
// You can use the properties as Immutable by accessing ``this.data``.
this.triggerEvent('toggle', { item: this.data.get('item') })
},
},
})
MIT © yelo, 2017 - present
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。