【发布时间】:2020-07-22 23:48:56
【问题描述】:
我想通过点击更改图像,但它不起作用:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/build/tailwind.css" />
<title>Document</title>
</head>
<body class="bg-black">
<h1 class="text-4xl font-bold text-center text-blue-500">Hello world!</h1>
<lottie-player
src="https://assets7.lottiefiles.com/private_files/lf30_vAtD7F.json"
background="transparent"
speed="1"
style="width: 300px; height: 300px;"
loop
autoplay
id="img"
onclick="change()"
>
</lottie-player>
<script src="../js/index.js"></script>
<script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"></script>
</body>
</html>
function change() {
document.getElementsByName('lottie-player').src = 'https://assets7.lottiefiles.com/packages/lf20_uzCbcN.json';
}
我在控制台上收到了这个错误:
【问题讨论】: