使用vscode进行调试
- 去vue仓库下载源码
- 修改package.json,打包生成sourcemap
"dev": "rollup -w -c scripts/config.js --environment TARGET:web-full-dev --sourcemap",
- npm run dev 生成dist文件
- 在项目根目录新建index.html,引入vue.js
<!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">
<title>Document</title>
<script src="./dist/vue.js"></script>
</head>
<body>
<div id="app">
<div v-for="(item, index) in arr" :key="index">{{item.name}}</div>
<button @click="show=true">显示</button>
<div v-if="show">aaaa</div>
</div>
<script>
let vm = new Vue({
el:"#app",
data: {
name:'zs',
arr:[
{id:1,name:'2'},
{id:2,name:'4'},
{id:3,name:'6'},
],
show:false
},
created() {
this.init()
},
mounted() {
console.log('mounted')
},
computed: {
calc() {
return this.name + 'computed'
}
},
watch: {
name(n,o) {
console.log(n,o)
}
},
methods: {
init() {
console.log('init')
}
},
})
</script>
</body>
</html>
- 点击调试,新建launch.json,把入口文件配置为index.html
6.在想打断点的位置点击
7.点击绿色三角即可开启调试
浏览器调试
使用Chrome打开index.html,在source中打开index.html,在相应位置打上断点即可开启调试