当前位置: 首页 > news >正文

【前端】vscode javascript 代码片段失效问题解决

1. 文件--首选项--用户代码片段-vue.json : 添加

 

// {
// 	// 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>","//这里可以导入其他文件(比如:组件,工具 js,第三方插件 js,json文件,图片文件等等)","//例如:import 《组件名称》 from '《组件路径》';","","export default {","//import 引入的组件需要注入到对象中才能使用","components: {},","props: {},","data() {","//这里存放数据","return {","","};","},","//计算属性 类似于 data 概念","computed: {},","//监控 data 中的数据变化","watch: {},","//方法集合","methods: {","","},","//生命周期 - 创建完成(可以访问当前 this 实例)","created() {","","},","//生命周期 - 挂载完成(可以访问 DOM 元素)","mounted() {","","},","beforeCreate() {}, //生命周期 - 创建之前","beforeMount() {}, //生命周期 - 挂载之前","beforeUpdate() {}, //生命周期 - 更新之前","updated() {}, //生命周期 - 更新之后","beforeDestroy() {}, //生命周期 - 销毁之前","destroyed() {}, //生命周期 - 销毁完成","activated() {}, //如果页面有 keep-alive 缓存功能,这个函数会触发","}","</script>","<style  scoped>","$4","</style>"],"description": "生成 vue 模板"},"http-get 请求": {"prefix": "httpget","body": ["this.\\$http({","url: this.\\$http.adornUrl(''),","method: 'get',","params: this.\\$http.adornParams({})","}).then(({data}) => {","})"],"description": "httpGET 请求"},"http-post 请求": {"prefix": "httppost","body": ["this.\\$http({","url: this.\\$http.adornUrl(''),","method: 'post',","data: this.\\$http.adornData(data, false)","}).then(({ data }) => { });"],"description": "httpPOST 请求"}
}

 在category.vue 文件空白处输入h ,可以显示用户片段

 在<script>中使用失败

 问题原因和解决: 在<script>使用的代码片段写在 javacript.json 中才能使用

VScode-Vue-用户代码片段无效 - Code World

 

 

 

 

http://www.lryc.cn/news/132632.html

相关文章:

  • AE-卡通人物解说动画视频的制作
  • Linux 查看日志
  • 使用IO多路复用select完成TCP循环服务器接收客户端消息并打印
  • unity之Input.GetKeyDown与Input.GetKey区别
  • excel 核心快捷键用法
  • postgresql
  • AutoSAR配置与实践(基础篇)3.2 BSW中的I/O架构和模块详解
  • 基于Java+SpringBoot+Vue的学校田径运动会管理系统【源码+论文+演示视频+包运行成功】
  • 使用 Visual Studio Code Docker 工具调试 .NET 容器
  • AI引擎助力,CamScanner智能高清滤镜开启扫描新纪元!
  • opencv进阶07-支持向量机cv2.ml.SVM_create()简介及示例
  • LA@n维向量@解析几何向量和线性代数向量
  • go 协程并发数控制
  • MySQL的安装以及卸载
  • LRU算法与Caffeine、Redis中的缓存淘汰策略
  • HTML笔记(3)
  • c++——重写(覆盖),实际上对应的就是虚函数
  • 算法通关村——字符串反转问题解析
  • vue + elementui 中 在弹框中使用了 tree型结构(<el-tree></el-tree>),点击关闭按钮按钮重置tree
  • windows adb根据id点击按钮
  • netty(一):NIO——处理消息边界
  • 等保测评--安全计算环境--测评方法
  • open cv学习 (二)色彩空间和通道
  • RS232、RS422、RS485硬件及RS指令、RS2指令应用知识学习
  • 背景属性样式
  • 蓝桥杯每日N题 (消灭老鼠)
  • k8s 用户角色 权限的划分
  • 聊一下操作系统 macOS 与 Linux
  • OJ练习第153题——分发糖果
  • iOS 通知推送服务端部署测试过程详细版