vue 项目中的坑 在项目中遇到 持续更新ing

1.vue2.0 不支持 v-html 后绑定的内容使用过滤,可是有时候过滤必须使用-----------解决:通过methods中定义方法 然后 v-html='myMethods(string)'

2.笔者使用的mintui

 <mt-header title="aaaa">
        <router-link :to="{name:'Search'}" slot="right">
            <mt-button icon="search">
            </mt-button>
        </router-link>
    </mt-header>

当想要给mt-button绑定@click事件 让其 this.$router.push({name:'Search'})的时候并不起作用,一直没有注意到mint给mt-button外边包了一层 router-link,其实只要在router-link中添加就好了,小bug累死人

3.继续坑爹的mint

<div @click='setValue(item)' v-for="(item,index) in result" :key='index'>
                <mt-cell  :title="item.name" :value="item.type|fromatSearchResult"  >
            </mt-cell>
           </div>

由于mt-cell绑定click事件不起作用,我想到了外边包一层 div让后在div上绑定事件 ,亲测可用,要是你一直怀疑自己写错了click事件那你就慢慢找原因吧,其实都是坑爹的mint造成的,适当的相信自己怀疑下框架!!

4.还是mint

 <mt-search v-model="value" placeholder="搜索概念" @keydown.enter="searchMsg" @keyup.enter.native="searchMsg">
           <div @click='setValue(item)' v-for="(item,index) in result" :key='index'>
                <mt-cell  :title="item.name" :value="item.type|fromatSearchResult"  >
            </mt-cell>
           </div>
        </mt-search>

在移动端有没有发现绑了keyup pc调试不起作用,在vue2.0中 如果是为自定义组件绑定原生事件必须使用 .native 修饰符

5.在项目中发现只有localhost 才能访问

  首先需要在config目录下找到index.js,然后找到host,把  host: 'localhost' ==>替换为host: '0.0.0.0' ,你就会发现 localhost, 127.0.01 ,你的ip都可以使用了

原文地址:https://www.cnblogs.com/fuzitu/p/8522297.html