javascript - When the vue component communicates through eventBus, an error a.$on is not a function is reported
怪我咯
怪我咯 2017-05-16 13:31:37
0
1
1210

Login component
import bus from "@/components/eventBus"
export default {
name: 'login',
data () {

return { navcard:['首页','工作室简介','人员分工','项目计划','重点故障分析','技能创新','带徒传技','技能培训','技术交流论坛'], username:'', userpassword:'', loginstate:'3' } }, methods:{ login:function(){ this.$http.get("http://localhost/web/njndc1/api.php",{params:{ 'username':this.username,'userpassword':this.userpassword,'action':'login' }}).then( function (res) { // 处理成功的结果 this.loginstate=res.body; console.log(this.loginstate) if(res.body==1){ var self=this; this.$router.push('/mainpage') bus.$emit("login_loginstae",'success') }else{ bus.$emit("login_loginstae",'failed') } },function (res) { // 处理失败的结果 alert('程序错误') } ); }

}
}

Main page component

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all (1)
我想大声告诉你

Solved. My original file directory put eventBus in src/components, and the file name was .vue. Later, I put it directly under assets/ and changed the file name to .js. The problem was solved

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!