• 微信小程序转uniapp时常见的语法变化


    • 属性绑定从 attr="{{ a }}",改为 :attr="a";从 title="复选框{{ item }}" 改为 :title="'复选框' + item"
    • 事件绑定从 bind:click="toggleActionSheet1" 改为 @click="toggleActionSheet1",目前支付宝小程序不支持 vue 的事件绑定方式,具体参考:支付宝小程序组件事件监听示例
    • 阻止事件冒泡 从 catch:tap="xx" 改为 @tap.native.stop="xx"
    • wx:if 改为 v-if
    • wx:for="{{ list }}" wx:key="{{ index }}" 改为v-for="(item,index) in list"

    1.官方推荐的正则公式:

    1 str = str.replace(/bindtap/g, '@onclick');  
    2 str = str.replace(/wx:if/g, 'v-show');  
    3 str = str.replace(/src=\'\{\{/g, ":src='");  
    4 str = str.replace(/wx\:key=\"\*this\"/g, ' ');  
    5 str = str.replace(/wx\:key\=\"index\"/g, ' ');  
    6 str = str.replace(/wx:for="{{/g, v-for= "(item,index) in ');  
    7 str = str.replace(/bindinput/g, '@input'); 

    详细内容见:https://ask.dcloud.net.cn/article/35786

  • 相关阅读:
    TS之类的继承
    TS之函数及函数传参
    TS之数据类型
    Linux 协程
    设计模式 装饰器模式和代理模式
    C/C++ C和C++的区别
    C/C++ 内存分配方式
    Linux 进程间通信
    C/C++ RTTI
    Reactor设计模式
  • 原文地址:https://www.cnblogs.com/qq2806933146xiaobai/p/15846204.html
Copyright © 2020-2023  润新知