svg 是可以执行 js 的,大家需要注意,下方是示例代码:
```
<svg xmlns="
http://www.w3.org/2000/svg" viewBox="0 0 360 640" preserveAspectRatio="xMidYMid meet" xmlns:xlink="
http://www.w3.org/1999/xlink">
<style>
text {
font-size: 24px;
text-anchor: middle;
dominant-baseline: middle;
fill: #333;
}
a {
text-decoration: none;
}
</style>
<a xlink:href="
https://www.baidu.com">
<text x="50%" y="10%" id="hello">loading...</text>
</a>
<script type="application/ecmascript">
<![CDATA[
setTimeout(function() {
var textElement = document.getElementById('hello');
textElement.textContent = "点击跳转";
}, 1500);
]]>
</script>
</svg>
```
保存为 test.svg 双击即可运行 js 代码,改成 test.xml 也是一样的道理。