首页 > Vuejs组件的单元测试怎么写

Vuejs组件的单元测试怎么写

比如我要有个组件Hello,需要从父组件中传入props,jasmine测试的话要怎么写?

describe('Hello.vue',function(){
    it('should have props from father',function(){
        const ob = {name:"jack"}
        const vm = new Vue({
            template:"<div><hello :ob='ob'></hello></div>"
            components:{Hello}
        })
    })
})

这样写是不行的,ob不能传入到hello组件中


数据要放在data中:

const ob = {name:"jack"}
const vm = new Vue({
            template:"<div><hello :ob='ob'></hello></div>"
            components:{Hello},
            data: {ob: ob}
})

for more: http://vuejs.org/guide/application.html#...

【热门文章】
【热门文章】