Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.3k views
in Technique[技术] by (71.8m points)

vue组件内方法抽取问题

有几个组件里都使用了一些方法,都写在methods里了。
这些方法里用了很多data里的变量,有很多this.xxx this.yyy this.zzz等等,大概有10个变量。
我想把这些方法提出来放到一个js里,然后import到vue组件里。
但这些方法内部的变量怎么提取出来呢?
都通过传参传进去吗?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

data 数据是公共变量吗?不是的话,试试 Vue.mixin()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...