uni-app编译到微信小程序无法使用微信小程序的Skyline
uni-app编译到微信小程序无法使用微信小程序的Skyline
示例代码:
<template>
<view class="content">
<view id="moved-box"></view>
<view id="btn" bind:tap="tap">点击驱动小球移动</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
};
},
onLoad() {
console.log(this);
const offset = wx.worklet.shared(0);
this.applyAnimatedStyle('#moved-box', () => {
'worklet';
return {
transform: `translateX(${offset.value}px)`
};
});
this._offset = offset;
},
methods: {
tap() {
// 点击时修改 sharedValue 值,驱动小球移动
this._offset.value = Math.random();
}
}
};
</script>
操作步骤:
微信小程序开启 Skyline 渲染模式:
pages.json
:
{
"path": "pages/index/index",
"style": {
"navigationStyle": "custom",
"renderer": "skyline",
"disableScroll": true,
"componentFramework": "glass-easel"
}
}
manifest.json
:
"appid" : "",
"setting" : {
"urlCheck" : false,
"es6" : true
},
"usingComponents" : true,
"lazyCodeLoading" : "requiredComponents",
"rendererOptions" : {
"skyline" : {
"defaultDisplayBlock" : false,
"defaultContentBox" : false
}
}
微信开发者工具, 开启Skyline 渲染调试
预期结果:
成功调用 this.applyAnimatedStyle
方法, 且点击按钮能使小球移动
实际结果:
控制台报错:
vendor.js? [sm]:4023 [Vue warn]: Error in onLoad hook: "TypeError: this.applyAnimatedStyle is not a function"
(found in pages/index/index.vue)(env: Windows,mp,1.06.2308310; lib: 3.1.5)
bug描述:
uniapp vue2 编译到微信小程序, 开启微信小程序的Skyline, 无法调用 this.applyAnimatedStyle
方法
更多关于uni-app编译到微信小程序无法使用微信小程序的Skyline的实战教程也可以访问 https://www.itying.com/category-93-b0.html
5 回复
写法不对,具体可参考此issue五楼附件wxSkylineDemo.zip
更多关于uni-app编译到微信小程序无法使用微信小程序的Skyline的实战教程也可以访问 https://www.itying.com/category-93-b0.html
回复 Yannis_: this.$scope.applyAnimatedStyle()
回复 zZZ1Ma: 感谢