vue的实例属性$options是用来获取定义在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>

 

相关文章:

  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2022-01-07
猜你喜欢
  • 2022-03-07
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案