文件-->首選項(xiàng)-->用戶代碼片段-->點(diǎn)擊新建代碼片段--取名 vue.json 確定
{
"生成 vue 模板": {
"prefix": "vue",
"body": [
"<template>",
"<div></div>",
"</template>",
"",
"<script>",
"http://這里可以導(dǎo)入其他文件(比如:組件,工具 js,第三方插件 js,json文件,圖片文件等等)",
"http://例如:import 《組件名稱》 from '《組件路徑》';",
"",
"export default {",
"http://import 引入的組件需要注入到對象中才能使用",
"components: {},",
"props: {},",
"data() {",
"http://這里存放數(shù)據(jù)",
"return {",
"",
"};",
"},",
"http://計(jì)算屬性 類似于 data 概念",
"computed: {},",
"http://監(jiān)控 data 中的數(shù)據(jù)變化",
"watch: {},",
"http://方法集合",
"methods: {",
"",
"},",
"http://生命周期 - 創(chuàng)建完成(可以訪問當(dāng)前 this 實(shí)例)",
"created() {",
"",
"},",
"http://生命周期 - 掛載完成(可以訪問 DOM 元素)",
"mounted() {",
"",
"},",
"beforeCreate() {}, //生命周期 - 創(chuàng)建之前",
"beforeMount() {}, //生命周期 - 掛載之前",
"beforeUpdate() {}, //生命周期 - 更新之前",
"updated() {}, //生命周期 - 更新之后",
"beforeDestroy() {}, //生命周期 - 銷毀之前",
"destroyed() {}, //生命周期 - 銷毀完成",
"activated() {}, //如果頁面有 keep-alive 緩存功能,這個(gè)函數(shù)會(huì)觸發(fā)",
"}",
"</script>",
"<style scoped>",
"$4",
"</style>"
],
"description": "生成 vue 模板"
}
}