Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k views
in Technique[技术] by (71.8m points)

javascript - Cannot use import statement outside a module in Vuejs. Template Django

I'm using a django template and using Vue only on the current page.

however when importing the lib, an error is displayed.

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
    <div id="app">
        <el-container style="height: 100vh;">
        <el-header>
            <el-row>
                <el-col :span="12" style="text-align: left;">
                    <el-image
                        style="width: 110px;"
                        src="img/logo-royal.png"
                        fit="fit">
                    </el-image>
                </el-col>
                <el-col :span="12" style="float: right;">
                    <menu-header></menu-header>
                </el-col>
            </el-row>
        </el-header>
        <el-container>
            <el-container>
                <el-main>
                    .....
content
.....
                </el-main>
            </el-container>
        </el-container>
        <el-footer style="font-size: 11px;">info</el-footer>
        </el-container>
    </div>
</body>

<script src="js/lib/vue.js"></script>
<script src="js/lib/apexcharts.js"></script>
<script src="js/lib/vue3-apexcharts.js"></script>

<script>
import VueApexCharts from 'vue-apexcharts'

var app = new Vue({
    el: '#app',
    components:{
      apexchart: VueApexCharts    <---- Uncaught SyntaxError: Cannot use import statement outside a module

    },
    data() {
        return {
          
    }
    },
    methods: {

    }
});
</script>
</html>

Uncaught SyntaxError: Cannot use import statement outside a module


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Absence of type="module" causes this problem usually.

You can give it a try.

<script type="module">
   // your code
</script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...