While traditional Vue components require a data function which returns an object and a method object with your handlers, vue-class-componentflattens component development by allowing you to add your data properties and handlers directly as properties of your class.

Install:

npm i --save vue-class-component vue-property-decorator

jsonfing.json:

{
"compilerOptions": {
"experimentalDecorators": true
}
}

HelloWorld.vue:

<template>
<div @click="onClick" class="hello">
{{message}}
</div>
</template> <script> import {Component, Prop, Vue} from 'vue-property-decorator' @Component({})
export default class HelloWorld extends Vue {
@Prop({
default: 'Default message from Hello World Component'
})
message onClick() {
this.message = 'Goodbye'
}
}
</script>

[Vue @Component] Define Props on a Vue Class with vue-property-decorator的更多相关文章

  1. [Vue @Component] Pass Props Between Components with Vue Slot Scope & renderless component

    Components with slots can expose their data by passing it into the slot and exposing the data using  ...

  2. [Vue @Component] Pass Props to Vue Functional Templates

    Functional templates allow you to create components consisting of only the template tag and exposing ...

  3. Vue组件选项props

    前面的话 组件接受的选项大部分与Vue实例一样,而选项props是组件中非常重要的一个选项.在 Vue 中,父子组件的关系可以总结为 props down, events up.父组件通过 props ...

  4. vue.js实战——props数据验证(自定义构造器检测)

    Vue.component('my-component',{ props:{ //必须是数字类型 propA:Number, //必须是字符串或数字类型 propB:[String,Number], ...

  5. vue.js实战——props单向数据流

    Vue2.x通过props传递数据是单向的了,也就是父组件数据变化时会传递给子组件,但是反过来不行. 业务中会经常遇到两种需要改变prop的情况, 一种是父组件传递初始值进来,子组件将它作为初始值保存 ...

  6. 【转存】Vue组件选项props

    原帖地址 前面的话 组件接受的选项大部分与Vue实例一样,而选项props是组件中非常重要的一个选项.在 Vue 中,父子组件的关系可以总结为 props down, events up.父组件通过  ...

  7. Vue组件之props,$emit与$on以及slot分发

    组件实例之间的作用域是孤立存在,要让它们之间的信息互通,就必须采用组件的通信方式  props用于父组件向子组件传达信息 1.静态方式 eg: <body> <div id=&quo ...

  8. element-ui + el-dialog + Vue.component 注册的富文本控件 第二次及以后打开dialog出现问题解决方法

    自定控件 添加属性  v-if="dialogVisible" <el-dialog title="" :visible.sync="dialo ...

  9. 前端框架vue.js系列(9):Vue.extend、Vue.component与new Vue

    前端框架vue.js系列(9):Vue.extend.Vue.component与new Vue 本文链接:https://blog.csdn.net/zeping891103/article/det ...

随机推荐

  1. C# 输出控制台结果到文件

    StreamWriter sw = new StreamWriter(@"c:\output.txt"); Console.SetOut(sw); Console.WriteLin ...

  2. Spring Boot (30) 上传文件

    文件上传 上传文件和下载文件是Java Web中常见的一种操作,文件上传主要是将文件通过IO流传输到服务器的某一个文件夹下. 导入依赖 在pom.xml中添加上spring-boot-starter- ...

  3. 为什么我的对象被 IntelliJ IDEA 悄悄的修改了?

    背景     最近,在复习JUC的时候调试了一把ConcurrentLinkedQueue的offer方法,意外的发现Idea在debug模式下竟然会 "自动修改" 已经创建的Ja ...

  4. HanLP自然语言处理包开源(包含源码)

    支持中文分词(N-最短路分词.CRF分词.索引分词.用户自定义词典.词性标注),命名实体识别(中国人名.音译人名.日本人名.地名.实体机构名识别),关键词提取,自动摘要,短语提取,拼音转换,简繁转换, ...

  5. C++ 模板template和template

    原文链接:https://blog.csdn.net/skyleung/article/details/42195509 template<class T>和template<typ ...

  6. golang协程——通道channel阻塞

    新的一年开始了,不管今天以前发生了什么,向前看,就够了. 说到channel,就一定要说一说线程了.任何实际项目,无论大小,并发是必然存在的.并发的存在,就涉及到线程通信.在当下的开发语言中,线程通讯 ...

  7. list.sort结果是None

    错误原因:  list.sort()功能是针对列表自己内部进行排序, 不会有返回值, 因此返回为None.  举例说明: In [19]: a=["a","c" ...

  8. acedssget F 方式

    ads_point p1; ads_point p2; acedGetPoint(NULL, _T("\n插入第一点"), p1); acedGetPoint(p1, _T(&qu ...

  9. 日常开发需要掌握的Maven知识

    文章来自:https://www.jianshu.com/p/e224a6dc8f20和https://www.jianshu.com/p/20b39ab6a88c Maven出现之前 jar包默认都 ...

  10. JavaScript 中实现 sleep

    来自推特上 Windows 故障分析的笑话 图片来源:me.me 推上看到的笑话,Windows 故障分析的实现. 然后想起来 JavaScript 中如何实现这个 sleep() 函数让代码暂停指定 ...