项目场景:
问题描述:
在vscode中使用axios无法绑定json数据输出到浏览器上
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- development version, includes helpful console warnings -->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<title>axios应用程序</title>
</head>
<body>
<div id="app">
<div>
名称:{{info.name}}
</div>
<div>
url:{{info.url}}
</div>
<ul>
<li v-for="onecontent in info.content">
{{onecontent.id}}--->{{onecontent.value}}
</li>
</ul>
</div>
<script>
var app = new Vue({
el: '#app',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
data() {
return {
info: {
name: '',
url: '',
content: []
}
}
},
mounted() {
axios
.get('data.json')
.then(response => this.info = response.data)
}
})
</script>
</body>
</html>
解决方案:
一.我们在win10 系统中有一个搜索框 输入 Windos PowerShell 一定要选择 管理员身份运行
二.打开了命令行之后,输入 set-ExecutionPolicy RemoteSigned
然后更改权限为A
最后通过 get-ExecutionPolicy 查看当前的状态
如下图:
三.在vscode终端中输入 live-server 浏览器自动打开 运行成功:
|