解决vue:import axios 报错 Uncaught SyntaxError: Cannot use import statement outside a module
import axios from "axios";beforeCreate: {renew: function () {axios.post('/renew/', {}).then(function (response) {console.log(response);}).catch(function (error) {console.log(error);}).then(func
·
import axios from "axios";
beforeCreate: function(){
axios.post('/renew/', {})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
})
.then(function () {
// always executed
});
},
报错:Uncaught SyntaxError: Cannot use import statement outside a module
尝试在head中插入:
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
未果。
解决方法
删除import axios from "axios";
完整正确导入方法:
在head中插入:
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
即可,不需要在写import了。
更多推荐
已为社区贡献1条内容
所有评论(0)