代码参考:https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/worklet.html
js:
Page({
onShow() {
this.animator = wx.createAnimation({
duration: 1000,
timingFunction: "linear"
});
this.animator.scale(1, 1).step();
this.setData({
animator: this.animator.export()
});
console.log(this.animator);
console.log(this.data);
},
listener(res) {
console.log(this.animator);
console.log(this.data);
this.animator.scale(3, 2).step();
this.setData({
animator: this.animator.export()
});
},
run(optional){
'worklet';
console.log('123wula coming',optional);
},
called:()=>{
this.run('at now');
wx.worklet.runOnUI(run)('now');
},
onLoad(res){
this.called();
}
});
wxml:
这是一个动画视图 点击我触发动画
报错信息:
TypeError: Cannot read property 'run' of undefined
你好,具体那个示例代码呢?
文档:https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/worklet.html
//文档代码
const name = 'skyline'
function anotherWorklet() {
'worklet';
return 'hello ' + name;
}
// worklet 函数间可互相调用
function someWorklet() {
'worklet';
const greeting = anotherWorklet();
console.log('another worklet says ', greeting);
}
wx.worklet.runOnUI(someWorklet)() // print: [ui] another worklet says hello skyline
//按照文档修改再次报错:
run(optional){
'worklet';
console.log('123wula coming',optional);
},
called(){
'worklet';
run('at now');
},
onLoad(res){
wx.worklet.runOnUI(called)();
}//ReferenceError: called is not defined
代码片段
https://developers.weixin.qq.com/s/wkAllvmX7fT1
基础库的问题,升级