如果在 template 中传递整个 data ?

发布于 7 年前作者 oxue13400 次浏览最后编辑 7 年前来自 ask

小程序开发中,需要在 template 组件中传递整个Page 的 data,目前是不是只能每个属性都手动写一遍?

因为在模板中没有办法直接访问到 data 这个变量,所以没办法直接用解构的写法,有些场景需要传递整个data就很麻烦。

1 回复
jdeng
jdeng1 楼5 年前

你是 this.data.myData 要传 this.data 吗,牛批牛批。

理论上 this.setData({ myData: this.data }) 是可行的,嚯哈哈哈,无言以对。