由于需要使用微信的开放标签,需要插入类似这样的代码
<wx-open-launch-weapp
id="launch-btn"
username="gh_xxxxxxxx"
path="pages/home/index?user=123&action=abc"
>
<script type="text/wxtag-template">
<style>.btn { padding: 12px }</style>
<button class="btn">打开小程序</button>
</script>
</wx-open-launch-weapp>
如果在vue2,<script>
是可以直接写进template的,但是在vue3会报 VueCompilerError: Tags with side effect (<script> and <style>) are ignored in client component templates.
错误在vuejs/vue-next/packages/compiler-dom/src/index.ts#L51 被抛出
但是不知道如何解决这个问题,或者有无迂回的方法
参考:
不知道是否有帮助
我也在答案中记一下:
通过
v-is
进行绕过:使用<div v-is="'script'"></div>
以替代<script>