1. 文件--首選項(xiàng)--用戶(hù)代碼片段-vue.json : 添加
?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-824154.html
// {
// // Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// // used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// // Placeholders with the same ids are connected.
// // Example:
// // "Print to console": {
// // "scope": "javascript,typescript",
// // "prefix": "log",
// // "body": [
// // "console.log('$1');",
// // "$2"
// // ],
// // "description": "Log output to console"
// // }
// }
{
"生成 vue 模板": {
"prefix": "vue",
"body": [
"<template>",
"<div></div>",
"</template>",
"",
"<script>",
"http://這里可以導(dǎo)入其他文件(比如:組件,工具 js,第三方插件 js,json文件,圖片文件等等)",
"http://例如:import 《組件名稱(chēng)》 from '《組件路徑》';",
"",
"export default {",
"http://import 引入的組件需要注入到對(duì)象中才能使用",
"components: {},",
"props: {},",
"data() {",
"http://這里存放數(shù)據(jù)",
"return {",
"",
"};",
"},",
"http://計(jì)算屬性 類(lèi)似于 data 概念",
"computed: {},",
"http://監(jiān)控 data 中的數(shù)據(jù)變化",
"watch: {},",
"http://方法集合",
"methods: {",
"",
"},",
"http://生命周期 - 創(chuàng)建完成(可以訪(fǎng)問(wèn)當(dāng)前 this 實(shí)例)",
"created() {",
"",
"},",
"http://生命周期 - 掛載完成(可以訪(fǎng)問(wèn) DOM 元素)",
"mounted() {",
"",
"},",
"beforeCreate() {}, //生命周期 - 創(chuàng)建之前",
"beforeMount() {}, //生命周期 - 掛載之前",
"beforeUpdate() {}, //生命周期 - 更新之前",
"updated() {}, //生命周期 - 更新之后",
"beforeDestroy() {}, //生命周期 - 銷(xiāo)毀之前",
"destroyed() {}, //生命周期 - 銷(xiāo)毀完成",
"activated() {}, //如果頁(yè)面有 keep-alive 緩存功能,這個(gè)函數(shù)會(huì)觸發(fā)",
"}",
"</script>",
"<style scoped>",
"$4",
"</style>"
],
"description": "生成 vue 模板"
},
"http-get 請(qǐng)求": {
"prefix": "httpget",
"body": [
"this.\\$http({",
"url: this.\\$http.adornUrl(''),",
"method: 'get',",
"params: this.\\$http.adornParams({})",
"}).then(({data}) => {",
"})"
],
"description": "httpGET 請(qǐng)求"
}
,
"http-post 請(qǐng)求": {
"prefix": "httppost",
"body": [
"this.\\$http({",
"url: this.\\$http.adornUrl(''),",
"method: 'post',",
"data: this.\\$http.adornData(data, false)",
"}).then(({ data }) => { });"
],
"description": "httpPOST 請(qǐng)求"
}
}
?在category.vue 文件空白處輸入h ,可以顯示用戶(hù)片段
?在<script>中使用失敗
?問(wèn)題原因和解決:?在<script>使用的代碼片段寫(xiě)在 javacript.json 中才能使用
VScode-Vue-用戶(hù)代碼片段無(wú)效 - Code World
?
?
?文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-824154.html
?
到了這里,關(guān)于【前端】vscode javascript 代碼片段失效問(wèn)題解決的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!