Taro踩坑记录(VUE多端同构)(2)
if(process.env.TARO_ENV === “h5”){
window.location.href = item.essayUrl
return
}
const url = encodeURIComponent(item.essayUrl);
Taro.navigateTo({
url: /pages/web-view/index?url=${url}
});
}
- app.config.js 配置
tabBar: {
custom: true,
/* … */
}
- tabbar页面记得引入自定义的tabbar组件
import customTabBar from “@/components/custom-tab-bar/index.vue”
export default {
components: { customTabBar },
onShow() {
this.$refs.tabBar.selected = 0
this.msgUnread = getGlobalData(“msgUnread”);
},
}
- 自定义tabbar组件
<cover-view
v-for=“(item, index) in list”
:key=“index”
class=“tab-bar-item”
@tap=“switchTab(item.pagePath, index)”
<cover-image
:src=“selected === index ? item.selectedIconPath : item.iconPath”
<cover-view
:style=“{ color: ${selected === index ? selectedColor : color} }”
{{ item.text }}</cover-view
注意CSS中使用PX保证不会自动转换为rpx
============================================================================
在config文件夹下index.js中
const path = require(‘path’)
const config = {
alias: {
‘@/components’: path.resolve(__dirname, ‘…’, ‘src/components’),
‘@/utils’: path.resolve(__dirname, ‘…’, ‘src/utils’),
‘@/constant’: path.resolve(__dirname, ‘…’, ‘src/constant’)
},
}
为避免报错,创建jsconfig.json
{
“compilerOptions”: {
“baseUrl”: “.”,
“paths”: {
“@/components/“: [”./src/components/”],
“@/utils/“: [”./src/utils/”],
“@/constant/“: [”./src/constant/”]
}
},
“exclude”: [“node_modules”, “dist”]
}
总结
秋招即将开始,校招的朋友普遍是缺少项目经历的,所以底层逻辑,基础知识要掌握好!
而一般的社招,更是神仙打架。特别强调,项目经历不可忽视;几乎简历上提到的项目都会被刨根问底,所以项目应用的技术要熟练,底层原理必须清楚。
这里给大家提供一份汇集各大厂面试高频核心考点前端学习资料。涵盖 HTML,CSS,JavaScript,HTTP,TCP协议,浏览器,Vue框架,算法等高频考点238道(含答案)!
开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】
资料截图 :



高级前端工程师必备资料包

更多推荐



所有评论(0)