<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>
vue的实例属性$options
最新推荐文章于 2024-04-26 16:47:03 发布