collapse 微信小程序_微信小程序转uni-app之实践问题汇总

本文总结了将微信小程序迁移到uni-app过程中遇到的问题,包括页面结构、资源路径、模板语法、样式导入、网络请求、生命周期、组件适配等方面,并提供了相应的修复方法和最佳实践。
摘要由CSDN通过智能技术生成

页面结构pages.json

"path" : "pages/my/index",

改为

"path" : "pages/my/my",

图片资源目录

"iconPath": "images/tabbar/home.png",

报错.png

改为

"iconPath": "static/tabbar/home.png",

template仅包含一个根view

根节点为 ,这个 下只能有一个根组件。

vue之class与style绑定

vue之class与style绑定.png

静态绑定

动态绑定

eg1:

eg2:

改为:

eg3:

{ {item.dept==0?'':(item.dept==99?positionArray[5].text:positionArray[item.dept-1].text)}}

改为:

{ {item.dept==0?'':(item.dept==99?positionArray[5].text:positionArray[item.dept-1].text)}}

eg4:

{ {item.title}}

改为:

{ {item.title}}

eg5:

{ {item}}

{ {orderList.sn[index]}}

¥{ {orderList.data[index]}}

报错:

Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.

改为:

{ {item}}

{ {orderList.sn[index]}}

¥{ {orderList.data[index]}}

eg6:

{ {item.state}}

{ {item.bg_time}}

改为:

{ {item.state}}

{ {item.bg_time}}

value双向绑定

报错

value="{ {keyword}}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of

, use

改为

循环渲染

改为

样式文件导入App.vue

export default {

onLaunch: function () {

console.log('App Launch')

},

onShow: function () {

console.log('App Show')

},

onHide: function () {

console.log('App Hide')

}

}

/*每个页面公共css */

@import 'graceUI/graceUI.css';

@import './commons/uni.css';

@import './commons/weui.css';

@import './commons/boot.css';

微信模拟器运行警告

警告

Now you can provide attr `wx:key` for a `wx:for` to improve performance.

定位

{ {item.name}}

改为

{ {item.name}}

pages.json文件用来对 uni-app 进行全局配置,决定页面文件的路径、窗口表现、设置多 tab 等

"window": {

"backgroundTextStyle": "light",

"navigationBarBackgroundColor": "#06a7e2",

"navigationBarTitleText": "uni-app",

"navigationBarTextStyle": "white"

},

改为

"globalStyle": {

"backgroundTextStyle": "light",

"navigationBarBackgroundColor": "#06a7e2",

"navigationBarTitleText": "uni-app",

"navigationBarTextStyle": "white"

},

定义全局函数和变量的位置和语法差异

小程序:app.js

App({

// ========== 全局数据对象(整个应用程序共享) ====

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
微信小程序的Vant Collapse是一个折叠面板组件,它可以将一组内容放置在多个折叠面板中,并通过点击面板的标题来展开或收缩其内容。你可以在Vant官方文档中找到关于Vant Collapse的详细介绍和使用方法。 在脚本流程中,你需要先获取使用的页面和组件,然后再获取这些组件中使用到的Vant组件。在获取到的组件中,你可以删除未使用到的Vant组件,以减小项目的体积。这样可以优化小程序的性能。 关于对Vant Collapse组件样式的修改,你可以使用Vant-weapp提供的样式类来尝试改变样式。如果你想要修改主面板的样式,你可以进一步探索如何实现。总结起来,Vant Collapse是一个非常实用的组件,可以帮助你实现折叠面板的功能,并通过自定义样式满足你的需求。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [小菜鸟的微信小程序 - 云开发 - 账号密码库(2)vant-weapp 组件样式修改](https://blog.csdn.net/tfnmdmx/article/details/119797803)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [微信小程序vant 按需引入](https://blog.csdn.net/lgldl/article/details/127605555)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值