[Vue] 問題の解決: 無効な補間構文

質問

図に示すように、補間構文は有効になりません。

ここに画像の説明を挿入します

エラー1

インポートVueと使用はVue2 つのタグ内に配置する必要があります

エラー例

<script type="text/javascript" src="./vue.js">
    Vue.config.productionTip = true

    const x = new Vue({
    
    
        el: '#root',
        data: {
    
    
            name:"zjh"
        }
    })

</script>

正しい例

<script type="text/javascript" src="./vue.js"></script>
<script type="text/javascript">
    Vue.config.productionTip = true

    const x = new Vue({
    
    
        el: '#root',
        data: {
    
    
            name:"zjh"
        }
    })

</script>

エラー2

を使用するコードは末尾に配置Vueする必要があります。javascriptbody

エラー例

<html>
    <head>
    
        <script type="text/javascript" src="./vue.js"></script>
        
        <script type="text/javascript">
            Vue.config.productionTip = true
            const x = new Vue({
    
    
                el: '#root',
                data: {
    
    
                    name:"zjh"
                }
            })
        </script>
        
    </head>
    <body>
        <div id="root">
            Hello, {
    
    {
    
    name}}
        </div>
    </body>
</html>

正しい例

<html>
    <head>
        <script type="text/javascript" src="./vue.js"></script>
    </head>
    <body>
        <div id="root">
            Hello, {
    
    {
    
    name}}
        </div>

        <script type="text/javascript">
            Vue.config.productionTip = true

            const x = new Vue({
    
    
                el: '#root',
                data: {
    
    
                    name:"zjh"
                }
            })
        </script>
    </body>
</html>

おすすめ

転載: blog.csdn.net/m0_50939789/article/details/128459138