- 1.代码执行顺序
- props - 》metheds -》data -》computer -》watch
- 2.mixins
- 对于公共的方法和属性做一个扩展
- 新建一个mixins文件-》share.ts (代码如下)
import { Component, Vue } from 'vue-property-decorator'
import { Toast } from 'vant'
const doman = process.env.DOMAIN
@Component
export default class shareMixins extends Vue {
mounted() {
this.shareMessage()
}
shareMessage() {
const shareData = {
title: '包大师邀你免费体验清洗服务',
link: `${doman}/activities/wash-new/`,
imgUrl: 'https://img.ibaodashi.com/20190531/c732ce61559c03907f9eda76280ace3d.png',
desc: '下载APP,即享1888元礼包券'
}
window.wxshare.ready(() => {
// 分享给朋友圈
window.wxshare.onMenuShareTimeline(shareData, {
success() {
Toast('分享成功')
}
})
// 分享给朋友
window.wxshare.onMenuShareAppMessage(shareData, {
success() {
Toast('分享成功')
}
})
})
}
}
import { Component, Mixins } from 'vue-property-decorator'
import share from '@/mixins/share'
export default class Login extends Mixins(share) {
内容正常写就ok
}
网友评论