vue的实例属性$options

$option 是用来获取data外面的数据和方法

<script>
export default {
  name: "Test",
  data() {
    return {
         
    };
  },
  //在data外面定义的属性和方法通过$options可以获取和调用
  name: "zs",
  age: 12,
  haha() {
    console.log("haha");
  },
  created() {  
    console.log(this.$options.name);  // zs
    console.log(this.$options.age);  //12
    this.$options.haha();  // haha
  
  },
</script>

 

posted @ 2019-08-12 14:34  氧化成风  阅读(2861)  评论(0编辑  收藏  举报