1)需要在开发者工具中,设置 > 安全 > 服务端口 ,设置为打开。
2)第一个例子:
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<text class="title">{{title}}</text>
</view>
<text>{{CalTotal}}</text>
<view v-for="(item,index) in list" :key="item.id">
<text>{{item.name}}</text>
</view>
</view>
</template>
<script setup>
import {computed, reactive, ref} from 'vue'
import {onLoad} from '@dcloudio/uni-app'
const title = ref('Hi,uniapp')
const list = reactive([{"id":1,"name":"A","total":1},{"id":2,"name":"B","total":2}])
const CalTotal = computed(() => {
return list.reduce((sum,cur) => sum + cur.total,0)
})
onLoad(() => {
console.log("onload");
})
</script>3) icon图标库:https://www.iconfont.cn/
4) 在page.json中配置底部导航条:
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#FF8C00",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"list": [{
"pagePath": "pages/index/index",
"iconPath": "static/images/index0.png",
"selectedIconPath": "static/images/index1.png",
"text": "首页"
}]
},5) 传统vue组件,需要安装、引用、注册,三个步骤后才能使用组件。easycom将其精简为一步。只要组件安装在项目的components目录下,并符合components/组件名称/组件名称.(vue|uvue)目录结构(。就可以不用引用、注册,直接在页面中使用。且需要在微信开发者工具的详情>本地设置中,去掉“上传时过滤无依赖文件”的勾选。