
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
这个项目希望实现用类似写 Vue 的方式来编写小程序。
$ npm i -S tua-wx
$ tnpm i -S @tencent/tua-wx
$ yarn add tua-wx
this.setData
computed
功能watch
功能import { TuaWxPage } from 'tua-wx'
// 使用 TuaWxPage 替代小程序提供的 Page
TuaWxPage({
// data 可以是类似 Vue 的函数形式(推荐),也可以是类似小程序的对象形式
// 注意:需要绑定的数据必须要先在 data 里声明!
// 因为 ES5 的 getter/setter 方法无法感知添加新的属性
data () {
return {
a: { b: 'b' },
c: [{ d: { e: 'e' } }],
f: 'f',
g: 'hello world',
}
},
// 计算属性
computed: {
// 注意这里是函数
reversedG () {
return this.g.split('').reverse().join('')
},
// 多个依赖也没问题
gAndAB () {
return this.g + ' + ' + this.a.b
},
},
// 方法建议都挂在 methods 下
methods: {
onTap () {
// 类似 Vue 的操作方式
this.f = 'onTap'
this.a.b = 'onTap'
this.c[0].d.e = 'onTap'
// 劫持了数组的以下方法: pop, push, sort, shift, splice, unshift, reverse
this.c.push('onTap')
// 对于不改变原数组的以下方法: map, filter, concat, slice...
// 建议采取直接替换原数组的方式
this.c = this.c.map(x => x + 1)
// 注意:请在 data 中先声明 x!否则无法响应 x 的变化...
this.x = 'x'
},
},
// 侦听器
watch: {
// 监听 data
g (newVal, oldVal) {
console.log('newVal', newVal)
console.log('oldVal', oldVal)
// 异步操作
setTimeout(() => {
this.a.b = 'new a.b from watch'
}, 1000)
},
// 监听嵌套属性
'a.b' (newVal, oldVal) {
console.log('newVal', newVal)
console.log('oldVal', oldVal)
// 异步操作
setTimeout(() => {
this.msg = 'new msg from watch'
}, 1000)
}
// 监听 computed
reversedG (newVal, oldVal) {
// ...
},
},
// 小程序原本的生命周期方法也能使用
onLoad () {},
})
computed
的依赖,这样可以精确地对变化的 computed
属性 setData
,而不是一股脑儿地将全部 computed
属性 setData
setData
FAQs
A helper for coding miniprogram like Vue
The npm package tua-wx receives a total of 0 weekly downloads. As such, tua-wx popularity was classified as not popular.
We found that tua-wx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.