【发布时间】:2021-10-24 09:14:44
【问题描述】:
我有一个名为 congratulations.json 的抽签动画 json 文件。我在 lottie player 标签 中包含了 src 中的文件路径,如下所示:
<lottie-player
class="justify-content-center"
src="../../../congratulations.json"
background="transparent"
speed="1"
style="width: 300px; height: 300px"
loop
controls
autoplay
></lottie-player>
我想在 vue.js 中点击一个按钮时启动这个抽奖播放器动画。
我的代码是这样的:
<div class="justify-content-center">
<button v-on:click="cong" class="btn">
animation
</button>
</div>
methods: {
cong() {
<lottie-player
class="justify-content-center"
src="../../../congratulations.json"
background="transparent"
speed="1"
style="width: 300px; height: 300px"
loop
controls
autoplay
></lottie-player>;
},
}
但它不起作用。我是否需要安装任何插件/扩展或我的代码不正确?
【问题讨论】:
-
尝试在路径前添加 telda
~以便 webpack 理解这是一条路径 -
请告诉我在哪里包含 telda。我不清楚。
-
nvm,查了一下,它似乎只适用于 CSS,应该是
src="~../../../congratulations.json"