我正在尝试切换“d”值并将其替换为动态生成的数字,但我不断将“意外数字”作为输出。这是我现在拥有的:
<path id="pathA" d="M 0 0 l 0 255" stroke="none" stroke-width="0" fill="none"/>
<script>
var sink = document.getElementById("pathA");
sink.setAttribute("d", M 0 0 l 0 (round*25.5));
</script>
答案 0 :(得分:1)
您提供的脚本有两个问题。
首先,您传递给setAttribute的第二个参数不正确。尝试:
sink.setAttribute(“d”,“M 0 0 1 0”+(round * 25.5));
其次,您不会在任何时候为round
提供值。