Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
这个项目希望实现用类似写 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 1 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
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.