Visual Studio Code Vue代码片段 总览

文章目录

    • 一、模板篇
      • 1. 初始化.vue       文件模板
      • 2. template 作用域插槽模板
    • 二、响应提示篇
      • 1. error       响应 !200提示
      • 2. success 响应     200提示
    • 三、axios请求篇
      • 1. axios get    请求
      • 2. axios post   请求
      • 3. axios put    请求
      • 4. axios delete请求
    • 四、事件篇
      • 4.1. @click    Event
      • 4.2.
      • 4.3. 页面跳转 Event
      • 4.4. 重置清空input Event
      • 4.5. 校验通用 Event
      • 4.6. 添加预校验
    • 五、日志输出篇
      • 5.1. cons打印输出
    • 总览

代码片段设置
【设置】-【用户代码片段】-【xxx.code.snippets】

默认xxx.code.snippets文件内容:
{}

在这里插入图片描述
在这里插入图片描述

一、模板篇

1. 初始化.vue       文件模板

"Vue init template": {"prefix": "tss","body": ["<!-- 模板区域 -->","<template>","<div>","<!-- 模板内容 -->","","</div>","</template>","","<!-- 行为区域 -->","<script>","export default {","  // 数据存放区域","  data () {","    return {","    }","  },","  // 生命周期函数","  created () {","  },","  // 方法函数","  methods: {","  },","  // 计算属性","  computed: {","  }","}","</script>","<!-- 样式区域 -->","<style lang='less' scoped>","","</style>",""],"description": "Vue init template"}

2. template 作用域插槽模板

	"template 作用域插槽模板": {"prefix": "tsc","body": ["<template slot-scope=\"scope\">","","</template>",],"description": "template 作用域插槽模板"}

释义:需要安装2个开发依赖
在这里插入图片描述
在这里插入图片描述

二、响应提示篇

1. error       响应 !200提示

"err200 消息提示": {"prefix": "err2","body": [" if (res.meta.status !== 200) {","   return this.\\$message.error('失败')"," }"," this.\\$message.success('成功!')"],"description": "err200 消息提示"}

2. success 响应     200提示

"success 消息提示": {"prefix": "sucmsg","body": ["this.\\$message.success('成功')"],"description": "success 消息提示"}

三、axios请求篇

1. axios get    请求

"axios get请求": {"prefix": "aget","body": ["const { data:res } = await this.\\$http.get('')"," if (res.meta.status !== 200) {","   return this.\\$message.error('失败')"," }"," this.\\$message.success('成功!')"],"description": "axios get请求"}

2. axios post   请求

axios post请求": {"prefix": "apost","body": ["const { data:res } = await this.\\$http.post('')"," if (res.meta.status !== 200) {","   return this.\\$message.error('失败')"," }"," this.\\$message.success('成功!')"],"description": "axios post请求"}

3. axios put    请求

axios put请求": {"prefix": "apost","body": ["const { data:res } = await this.\\$http.put('')"," if (res.meta.status !== 200) {","   return this.\\$message.error('失败')"," }"," this.\\$message.success('成功!')"],"description": "axios put请求"}

4. axios delete请求

axios delete请求": {"prefix": "apost","body": ["const { data:res } = await this.\\$http.delete('')"," if (res.meta.status !== 200) {","   return this.\\$message.error('失败')"," }"," this.\\$message.success('成功!')"],"description": "axios delete请求"}

四、事件篇

4.1. @click    Event

"@click 事件": {"prefix": "@cli","body": ["@click=\"\""],"description": "打印输出"}

4.2.

确认删除 Event

"删除确认 事件": {"prefix": "cdel","body": ["async removeById (id) {","  const confirmResult = await this.\\$confirm('此操作将永久删除该文件, 是否继续?', '提示', {","    confirmButtonText: '确定',","    cancelButtonText: '取消',","    type: 'warning'","  }).catch(err => err)","  if (confirmResult !== 'confirm') {","    return this.\\$message.info('已经取消了删除!')","  }","  const { data: res } = await this.\\$http.delete("," `goods/\\${id}`)","  if (res.meta.status !== 200) {","    return this.\\$message.error('删除xx失败')","  }","  this.\\$message.success('删除xx成功!')","  this.getXXXlist()","}",],"description": "删除确认 事件"}

4.3. 页面跳转 Event

"页面跳转 事件": {"prefix": "$ro","body": ["this.$router.push('/xxpage')",],"description": "页面跳转 事件"}

4.4. 重置清空input Event

"取消按钮 清空input 事件": {"prefix": "$refs","body": ["this.\\$refs.xxxFormRef.resetFields()",],"description": "取消按钮 清空input 事件"}

4.5. 校验通用 Event

"校验规则 事件": {"prefix": "rq","body": ["name: [","  { required: true, message: '请输入活动名称', trigger: 'blur' },","  { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }","]",],"description": "校验规则 事件"}

4.6. 添加预校验

"添加预校验": {"prefix": "arv","body": ["addUser () {","  this.\\$refs.addFormRef.validate(async valid => {","  // 验证不通过","  if (!valid) return","  // 可以发起添加用户的网络请求","   const { data: res } = await this.\\$http.post('xxxurl', this.addForm)","  // 返回响应判断"," if (res.meta.status !== 201) {","  this.\\$message.error('添加用户失败!')","  }","   this.\\$message.success('添加用户成功!')","  // 隐藏添加用户的对话框","  this.addDialogVisible = false","  // 重新获取用户列表数据","  this.getUserList()","   })","}",],"description": "添加用户预校验"}

五、日志输出篇

5.1. cons打印输出

"cons打印输出": {"prefix": "clog","body": ["console.log()"],"description": "cons打印输出"}

总览

{"Vue init template": {"prefix": "tss","body": ["<!-- 模板区域 -->","<template>","<div>","<!-- 模板内容 -->","","</div>","</template>","","<!-- 行为区域 -->","<script>","export default {","  // 数据存放区域","  data () {","    return {","    }","  },","  // 生命周期函数","  created () {","  },","  // 方法函数","  methods: {","  },","  // 计算属性","  computed: {","  }","}","</script>","<!-- 样式区域 -->","<style lang='less' scoped>","","</style>",""],"description": "Vue init template"},"error消息提示": {"prefix": "errmsg","body": ["return this.\\$message.error('失败')"],"description": "error消息提示"},"err200 消息提示": {"prefix": "err2","body": [" if (res.meta.status !== 200) {","   return this.\\$message.error('失败')"," }"," this.\\$message.success('成功!')"],"description": "err200 消息提示"},"template 作用域插槽模板": {"prefix": "tsc","body": ["<template slot-scope=\"scope\">","","</template>",],"description": "template 作用域插槽模板"},"success 消息提示": {"prefix": "sucmsg","body": ["this.\\$message.success('成功')"],"description": "success 消息提示"},"axios get请求": {"prefix": "aget","body": ["const { data:res } = await this.\\$http.get('')"," if (res.meta.status !== 200) {","   return this.\\$message.error('失败')"," }"," this.\\$message.success('成功!')"],"description": "axios get请求"},"axios post请求": {"prefix": "apost","body": ["const { data:res } = await this.\\$http.post('')"," if (res.meta.status !== 200) {","   return this.\\$message.error('失败')"," }"," this.\\$message.success('成功!')"],"description": "axios post请求"},"axios delete请求": {"prefix": "adel","body": ["const { data:res } = await this.\\$http.delete('')"," if (res.meta.status !== 200) {","   return this.\\$message.error('失败')"," }"," this.\\$message.success('成功!')"],"description": "axios delete请求"},"axios put请求": {"prefix": "aput","body": ["const { data:res } = await this.\\$http.put('')"," if (res.meta.status !== 200) {","   return this.\\$message.error('失败')"," }"," this.\\$message.success('成功!')"],"description": "axios put请求"},"cons打印输出": {"prefix": "clog","body": ["console.log()"],"description": "cons打印输出"},"@click 事件": {"prefix": "@cli","body": ["@click=\"\""],"description": "打印输出"},"删除确认 事件": {"prefix": "cdel","body": ["async removeById (id) {","  const confirmResult = await this.\\$confirm('此操作将永久删除该文件, 是否继续?', '提示', {","    confirmButtonText: '确定',","    cancelButtonText: '取消',","    type: 'warning'","  }).catch(err => err)","  if (confirmResult !== 'confirm') {","    return this.\\$message.info('已经取消了删除!')","  }","  const { data: res } = await this.\\$http.delete("," `goods/\\${id}`)","  if (res.meta.status !== 200) {","    return this.\\$message.error('删除xx失败')","  }","  this.\\$message.success('删除xx成功!')","  this.getXXXlist()","}",],"description": "删除确认 事件"},"页面跳转 事件": {"prefix": "$ro","body": ["this.$router.push('/xxpage')",],"description": "页面跳转 事件"},"取消按钮 清空input 事件": {"prefix": "$refs","body": ["this.\\$refs.xxxFormRef.resetFields()",],"description": "取消按钮 清空input 事件"},"校验规则 事件": {"prefix": "rv","body": ["name: [","  { required: true, message: '请输入活动名称', trigger: 'blur' },","  { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }","]",],"description": "校验规则 事件"},"添加预校验": {"prefix": "arv","body": ["addUser () {","  this.\\$refs.addFormRef.validate(async valid => {","  // 验证不通过","  if (!valid) return","  // 可以发起添加用户的网络请求","   const { data: res } = await this.\\$http.post('xxxurl', this.addForm)","  // 返回响应判断"," if (res.meta.status !== 201) {","  this.\\$message.error('添加用户失败!')","  }","   this.\\$message.success('添加用户成功!')","  // 隐藏添加用户的对话框","  this.addDialogVisible = false","  // 重新获取用户列表数据","  this.getUserList()","   })","}",],"description": "添加用户预校验"}
}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/520476.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

一个案例彻底弄懂如何正确使用 mysql inndb 联合索引

有一个业务是查询最新审核的5条数据 SELECT id, title FROM th_content WHERE audit_time < 1541984478AND status ONLINE ORDER BY audit_time DESC, id DESC LIMIT 5; 查看当时的监控情况 cpu 使用率是超过了100%&#xff0c;show processlist看到很多类似的查询都是处…

为你的AliOS Things应用增加自定义cli命令

在日常嵌入式开发中&#xff0c;我们经常会用串口命令来使设备进入某种特定的状态&#xff0c;或执行某个特定的操作。如系统自检&#xff0c;模拟运行&#xff0c;或者进入手动模式进行设备点动。linux下有强大的shell工具&#xff0c;可以让用户和片上系统进行交互&#xff0…

4________请拖拽到此区域5________请拖拽到此区域_5分钟学会:蒙版与通道(剪贴蒙版)...

剪贴蒙版可以用一个图层中包含像素的区域来限制它上层图像的显示范围。它的最大优点是可以通过一个图层来控制多个图层的可见内容&#xff0c;而图层蒙版和矢量蒙版都只能控制一个图层。1、实例&#xff1a;创建剪贴蒙版颜回&#xff1a;5分钟学会&#xff1a;蒙版与通道 实例&…

一场高质量的技术盛会怎样炼成?「2019中国大数据技术大会」即将来临,邀您共赴!...

2019年12月&#xff0c;一场轰动国内产业界、学术界、科研界及投资领域的顶级科技盛会即将拉开帷幕&#xff0c;它涵盖大数据、人工智能、云计算、AIoT、金融科技、智能制造等十几个前沿领域的热门话题。在过去十二年里&#xff0c;这场盛会从最初仅 60 余人参加的技术沙龙到如…

在Developerkit开发板上运行blink例程

本文将介绍怎么样在VScode环境下&#xff0c;将AliOS Tings提供的blink例程在Developerkit开发板上运行起来。 DeveloperKit开发板 在例程中分别用到两个led和一个按钮&#xff0c;上图中用红色的框标识出来。例程正确运行后&#xff0c;会有一个LED按1s的周期闪烁&#xff0c…

阿里下一代云分析型数据库AnalyticDB入选Forrester云化数仓象限

前言 近期, 全球权威IT咨询机构Forrester发布"The Forrester Wave: CloudData Warehouse Q4 2018"研究报告&#xff0c;阿里巴巴分析型数据库(AnalyticDB)成功入选。 AnalyticDB作为阿里巴巴自主研发的PB级实时云数据仓库&#xff0c;全面兼容MySQL协议以及SQL:200…

俄罗斯互联网的BAT

戳蓝字“CSDN云计算”关注我们哦&#xff01;作者&#xff5c;挖数责编&#xff5c;阿秃1961年&#xff0c;尤里米尔纳 出生在莫斯科一个犹太人家庭&#xff0c;他的父亲是一名经济学家&#xff0c;母亲是一名医生&#xff0c;他儿时的梦想是成为科学家。高中毕业后&#xff0c…

fiq中断的入口地址_嵌入式技巧:ARM的三种中断调试方法介绍

嵌入式软件开发流程参照嵌入式软件的开发流程。第一步&#xff1a;工程建立和配置。第二步&#xff1a;编辑源文件。第三步&#xff1a;工程编译和链接。第四步&#xff1a;软件的调试。第五步&#xff1a;执行文件的固化。在整个流程中&#xff0c;用户首先需要建立工程并对工…

一文带你领略虚拟化领域顶级技术会议KVM Forum 2018

KVM Forum是由Linux基金会组织的高端技术论坛会议&#xff0c;主要为社区各个维护者&#xff0c;开发人员&#xff0c;和用户提供一个讨论Linux虚拟化技术发展趋势以及挑战的交流场所。参会人员都集中在KVM虚拟化相关领域&#xff0c;是KVM社区最为重要和权威的大会。 概述 2…

直击KubeCon 2018 |云原生正在改变你的衣食住行

云计算从不被看好到成长为势不可挡的技术潮流&#xff0c;仅仅用了十年的时间。如今“云原生”又被企业以及开发者奉为圭臬&#xff0c;并被认为是云计算的未来。 阿里云容器技术负责人易立认为云计算有三个阶段&#xff1a;云搬迁、云就绪和云原生。 第一个阶段是为了降低成…

玩大了!别再埋头学Python了,它真的无用!

在知乎上有一个特别火的问题&#xff1a;如何学Python&#xff1f;你会看到很多高赞回答是&#xff1a;我一天就学完了。在大家群嘲的背后&#xff0c;我们来分析一下&#xff0c;为什么在已经学过的人眼里&#xff0c;Python这么容易学&#xff0c;甚至简单到被某些人鄙视呢&a…

2020洪灾地图_卫星地图看洪灾:为何湖北易发洪水?

▲7月6日&#xff0c;武昌江滩凉亭被淹没。图片来源&#xff1a;中国气象局疫情甫定&#xff0c;洪水又来。入汛以来&#xff0c;长江中下游地区的日子并不好过。荆楚大地湖北遭遇多轮强降雨&#xff0c;引发严重洪涝灾害&#xff0c;让我们不禁将目光再次聚焦这里。荆楚大地为…

双十一高并发场景背后的数据库RDS技术揭秘

【战报】11月11日聚石塔&#xff08;阿里云数据库RDS产品形态&#xff09;峰值QPS突破X00w&#xff0c;Proxy 峰值QPS超过X00w。 双十一就要来了&#xff0c;全世界都为其疯狂&#xff0c;但是在双十一抢购中经常会出现几万人抢一个红包或者很多人共同购买一个商品的情况&…

Vue优化策略_项目发布_01

文章目录一、移除console 策略1. 命令1.1. 插件官网&#xff1a;1.2. 安装babel-plugin-transform-remove-console1.3. 在babel.config.js或者.babelrc文件中配置2. 图形化(推荐使用)2.1. 在线图形化安装插件2.2. 在babel.config.js或者.babelrc文件中配置二、生成打包报告1. 通…

双十一流量洪峰 支撑阿里核心业务的云数据库揭秘

背景介绍 今年双十一又有新纪录刷新&#xff0c;21秒成交额超10亿&#xff0c;数据瞬间膨胀到PB级&#xff0c;包裹数亿级&#xff0c;严苛的指标对数据库产品提出了更严格的需求。HybridDB作为阿里云自研的HTAP数据库经受住了流量洪峰的考验&#xff0c;顺利的完成了2019年双…

乘法原理的例题和答案_吃透高考数学17个必考题型,基础再差也能考130!(内附解题技巧+例题解析)...

2019高考数学难度比例为7&#xff1a;2&#xff1a;1&#xff0c;也就是说80%都是基础题。然而数学却是高考中最拉分的。90%的学生都缺少一套科学&#xff0c;高效的提分方法&#xff0c;尤其到了冲刺阶段&#xff01;为此&#xff0c;我们为大家整理了高考数学历年17个必考题型…

为何“爱辞职”成为了90后的又一标签?

戳蓝字“CSDN云计算”关注我们哦&#xff01;作者 | AlfredWu责编 | 阿秃金三银四金九银十&#xff0c;又到了每年的秋招时节。在各企业HR狂刷简历企图招贤纳士的同时&#xff0c;内部年轻员工心中实则也暗流涌动&#xff1a;他们有些已提交了辞呈&#xff0c;有些在骑驴找马物…

双11大考 POLARDB分钟级弹性让企业轻松扩展

POLARDB优势解读系列文章之——分钟级弹性 无处不在的脉冲计算 阿里有双11&#xff0c;中国有春运&#xff0c;高考后有分数出来的那天&#xff0c;歌迷心中有周杰伦演唱会门票在线开售之时。。。。有人的地方就有江湖&#xff0c;有人的地方也有脉冲计算&#xff0c;这些热点…

Vue优化策略_项目上线_02

接上一篇&#xff1a;Vue优化策略_项目发布_01 https://gblfy.blog.csdn.net/article/details/105359879 文章目录一、通过node创建web服务器1. 创建文件夹2. 初始化包管理配置文件3. 安装express插件4. 复制vue打包后dist5. 创建app.js配置6. 运行项目并浏览器访问二、开启gzi…

深度解析双十一背后的阿里云 Redis 服务

在一片欢呼之中&#xff0c;2018年的双十一完美收官&#xff0c;各项数据不出意外的刷出了新的记录&#xff0c;亮眼的数据背后是阿里过硬的技术支撑。其中阿里云Redis不仅保障了阿里集团内部业务双十一的流量洪峰平稳度过&#xff0c;也让使用阿里云Redis的各个客户度过了一个…