Vue3.0常用代码片段和开发插件
Vue3 Snippets for Visual Studio Code
This extension adds Vue3 Code Snippets into Visual Studio Code.
这个插件基于最新的 Vue3 的 API 添加了 Code Snippets。
Snippets / 代码片段
Including most of the API of Vue3. You can type reactive
, choose reactive
, and press ENTER, then const data = reactive({...})
appear on the screen.
插件的 Snippets 如下表格所示,比如你可以键入 reactive
然后按上下键选中 reactive
再按 Enter 键,就输入了const data = reactive({...})
了。
Prefix | JavaScript Snippet Content |
---|---|
import |
import {...} from "@vue/composition-api" |
import |
import {...} from 'vue' |
newVue |
newVue({...}) |
createComponent |
createComponent({...}) |
export |
export default { ... } |
setup |
setup(${...}) {...} |
reactive |
const data = reactive({...}) |
watch |
watch(..., ...) |
watchFn |
watch(() => {...}) |
computed |
computed(() => { get: () => {...}, set: () => {...}}) |
toRefs |
toRefs(...) |
ref |
ref(...) |
props |
props(...) |
onBeforeMount |
onBeforeMount(...) |
onMounted |
onMounted(...) |
onBeforeUpdate |
onBeforeUpdate(...) |
onUpdated |
onUpdated(...) |
onBeforeUnmount |
onBeforeUnmount(...) |
onUnmounted |
onUnmounted(...) |
onErrorCaptured |
onErrorCaptured(...) |
Vue Composition API
@vue/composition-api
使开发者们可以在 Vue 2.x
中使用 Vue 3.0
引入的基于函数的逻辑复用机制。
Navigation
Installation
npm
npm install @vue/composition-api --save
yarn
yarn add @vue/composition-api
CDN
<script src="https://unpkg.com/@vue/composition-api/dist/vue-composition-api.umd.js"></script>
By using the global variable window.vueCompositionApi.
通过全局变量 window.vueCompositionApi
来使用。
Usage
You must install @vue/composition-api via Vue.use() before using other APIs:
在使用任何 @vue/composition-api
提供的能力前,必须先通过 Vue.use()
进行安装:
import Vue from 'vue';
import VueCompositionApi from '@vue/composition-api';
Vue.use(VueCompositionApi);
After installing the plugin you can use the Composition API to compose your component.
安装插件后,您就可以使用新的 Composition API 来开发组件了。
TypeScript
This plugin requires TypeScript version >3.5.1. If you are using vetur
, make sure to set vetur.useWorkspaceDependencies
to true
.
To let TypeScript properly infer types inside Vue component options, you need to define components with createComponent
:
请使用最新版的 TypeScript,如果你使用了 vetur
,请将 vetur.useWorkspaceDependencies
设为 true
。
为了让 TypeScript 正确的推导类型,我们必须使用 createComponent
来定义组件:
import { createComponent } from '@vue/composition-api';
const Component = createComponent({
// 启用类型推断
});
const Component = {
// 无法进行选项的类型推断
// TypeScript 无法知道这是一个 Vue 组件的选项对象
};
TSX
Vue3.0常用代码片段和开发插件的更多相关文章
- 36个Android开发常用代码片段
//36个Android开发常用代码片段 //拨打电话 public static void call(Context context, String phoneNumber) { context.s ...
- C#常用代码片段备忘
以下是从visual studio中整理出来的常用代码片段,以作备忘 快捷键: eh 用途: 类中事件实现函数模板 private void MyMethod(object sender, Event ...
- Jquery学习总结(1)——Jquery常用代码片段汇总
1. 禁止右键点击 ? 1 2 3 4 5 $(document).ready(function(){ $(document).bind("contextmenu",fun ...
- Atom编辑器折腾记_(15)JS代码片段补全(插件:javascript-snippets)
题外话 这款插件就比較重量级了-.用熟悉了写原生JS的效率要提升非常多--并且,不仅支持JS还包括了nodejs snippet javascript-snippets 插件作者: zenorocha ...
- jQuery常用代码片段
检测IE浏览器 在进行CSS设计时,IE浏览器对开发者及设计师而言无疑是个麻烦.尽管IE6的黑暗时代已经过去,IE浏览器家族的人气亦在不断下滑,但我们仍然有必要对其进行检测.当然,以下片段亦可用于检测 ...
- Android开发常用代码片段
拨打电话 public static void call(Context context, String phoneNumber) { context.startActivity( new Inten ...
- [工作总结]jQuery在工作开发中常用代码片段集锦(1-10)
1.jQuery,JS实现tab切换 原生JS实现 HTML代码如下: <div class="wrap"> <ul id="tag"> ...
- swift开发常用代码片段
// 绑定事件 cell.privacySwitch.addTarget(self, action: #selector(RSMeSettingPrivacyViewController.switch ...
- Play常用代码片段 http://www.anool.net/?p=625
持续更新中: (1)按照降序查询: List<Entity> entities= Entity.find("order by id desc").fetch(2); ...
随机推荐
- [考试反思]0927csp-s模拟测试53:沦陷
很喜欢Yu-shi说过的一句话 在OI里,菜即是原罪 对啊. 都会.谁信呢? 没有分数,你说话算什么呢? 你就是菜,你就是不对,没有别的道理. 最没有用的,莫过于改题大神,这就是菜的借口. 但是其实这 ...
- Python基本数据结构之文件操作
用word操作一个文件的流程如下: 1.找到文件,双击打开 2.读或修改 3.保存&关闭 用python操作文件也差不多: f=open(filename) # 打开文件 f.write(&q ...
- Python - selenium自动化-Chrome(headless)
什么是 Headless Chrome Headless Chrome 是 Chrome 浏览器的无界面形态,可以在不打开浏览器的前提下,使用所有 Chrome 支持的特性运行你的程序.相比于现代浏览 ...
- Spring Boot 2.X(十七):应用监控之 Spring Boot Admin 使用及配置
Admin 简介 Spring Boot Admin 是 Spring Boot 应用程序运行状态监控和管理的后台界面.最新UI使用vue.js重写里. Spring Boot Admin 为已注册的 ...
- win7 安装php插件imagick
win7 安装php插件imagick <h2>安装步骤:</h2><h2><a name="t1"></a> ...
- C++总结(1)keywords to the class
目录 Chapter 1.关于类的关键字 1. class,struct与union 2.private,public与protected 3.friend 4.virtual 5.const 6.i ...
- 深入理解 DNS
深入理解 DNS 简介 DNS(Domain Name System)域名系统,它是一个将域名和 IP 地址相互映射的一个分布式数据库,把容易记忆的主机名转换成主机 IP 地址. DNS使用 TCP ...
- pat 1132 Cut Integer(20 分)
1132 Cut Integer(20 分) Cutting an integer means to cut a K digits lone integer Z into two integers o ...
- pat 1100 Mars Numbers(20 分)
1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...
- ubunit 16 安装pip
pip是一个用来安装和管理python包的工具.已经内置到python2.7.9和python3.4及其以上的版本里. python2.7执行: sudo apt-get install python ...