求教:有哪个大神知道怎么使用vue的render函数写一个拖放接口,返回虚拟dom节点
1条回答
- qq_41126602 2017-12-04 11:02关注hahahhahggggggggggggg
<br> Vue.component('mycom',{<br> render:function(createElement){<br> var s=this;<br> if(this.v==1){<br> return createElement('div',<br> {<br> domProps:{innerHTML:'component n='+this.n}<br> })<br> }else{</p> <pre><code> return createElement('div', [this.$slots.slot1,this.$slots.slot2]) } }, props:{ v:{ type:Number, default:0 }, n:{ default:'hello' } } }); var app=new Vue({ el:'#app', data:{ nnum:1 } }) <div id="app"> <mycom :v="nnum" :ar="arr"> <div slot="slot2">hahahhah</div> <div slot="slot1">ggggggggggggg</div> </mycom> </div> <script> Vue.component('mycom',{ render:function(createElement){ if(this.v==1){ return createElement('div', this.ar.map(function(item){ return createElement('li', { domProps:{ innerHTML:item } }) }) ) }else{ return createElement('div', [this.$slots.slot1,this.$slots.slot2]) } }, props:{ v:{ type:Number, default:0 }, n:{ default:'hello' }, ar:{ type:Array, default:function(){ return [1,23,4,5,6,55,65]} } } }); var app=new Vue({ el:'#app', data:{ nnum:1, arr:[1,2,3,4,5,6,7,8] } }) </script> </body> </code></pre>解决 无用评论 打赏 举报
悬赏问题
- ¥50 永磁型步进电机PID算法
- ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
- ¥88 找成都本地经验丰富懂小程序开发的技术大咖
- ¥15 如何处理复杂数据表格的除法运算
- ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
- ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
- ¥200 uniapp长期运行卡死问题解决
- ¥15 latex怎么处理论文引理引用参考文献
- ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
- ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?