lottie-miniapp
lottie-miniapp copied to clipboard
这2天微信小程序加强了eval的审核限制,用了这个库一直审核不通过,麻烦看看是不是哪里违反了限制
小程序官方限制通知:https://developers.weixin.qq.com/community/minihome/doc/0000ae500e4fd0541f2ea33755b801
我是参照官方示例来引用线上文件包的,版本:[email protected]
lottieCreate(wx.createCanvasContext('lottie-cat'), {
path: 'https://xxxx/cat.zip',
width: 400,// 可不传
height: 400// 可不传
})
// 创建lottie动画
function lottieCreate(canvasContext, { path, width, height }) {
const lottie = require('./lottie').default// 引用本库文件
if (!canvasContext || !path) return
if (!width || !height) {// 不传默认设屏幕尺寸
const systemInfo = wx.getSystemInfoSync()
width = systemInfo.windowWidth
height = systemInfo.windowHeight
}
console.log('canvas尺寸:', width, height)
canvasContext.canvas = {
width,
height,
}
Object.defineProperty(canvasContext, "globalAlpha", {
get() {
return this._globalAlpha
},
set(value) {
this._globalAlpha = value
},
})
canvasContext.globalAlpha = 1
return lottie.loadAnimation({
renderer: "canvas",
loop: true,
autoplay: true,
path,
rendererSettings: {
context: canvasContext,
clearCanvas: true,
},
})
}
兄弟,你这个问题怎么解决?有可替代的库吗
@vcxiaohan @sky-chy 由于 lottie web 内部会有 eval 逻辑, 所以 lottie-miniapp 为了保持同步内部实现 eval
https://github.com/airbnb/lottie-web/blob/master/player/js/utils/expressions/ExpressionManager.js#L437 https://github.com/landn172/lottie-miniapp/blob/master/src/lottie/utils/expressions/ExpressionManager.js#L446
可以尝试自行编译将这行代码注释,尝试下是否可以运行 (某些lottie 文件会涉及到此处)。
可以使用官方维护方案 https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/extended/utils/api-typings.html