day04 uni-app起步

1.在HBuild X中新建uni-app
2.從icon-font下載自己所需要的logo,復制到static目錄下
3.配置pages.json
{
    "pages": [
        //pages數(shù)組中第一項表示應用啟動頁,參考:https://uniapp.dcloud.io/collocation/pages
        {
            "path": "pages/index/index",
            "style": {
                "navigationBarTitleText": "主頁"
            }
        },
        {
            "path": "pages/ucenter/ucenter",
            "style": {
                "navigationBarTitleText": "我的"
            }
        },
        {
            "path": "pages/ucenter/setting",
            "style": {
                "navigationBarTitleText": "個人設(shè)置"
            }
        }
    ],
    "tabBar": {
        "color": "#000000",
        "selectedColor": "#2F85FC",
        "backgroundColor": "#FFFFFF",
        "borderStyle": "black",
        "list": [{
                "pagePath": "pages/index/index",
                "iconPath": "static/home.png",
                "selectedIconPath": "static/home-active.png",
                "text": "主頁"
            },
            {
                "pagePath": "pages/ucenter/ucenter",
                "iconPath": "static/center.png",
                "selectedIconPath": "static/center-active.png",
                "text": "我的"
            }
        ]
    },
    "globalStyle": {
        "navigationBarTextStyle": "black",
        "navigationBarTitleText": "uni-app",
        "navigationBarBackgroundColor": "#F8F8F8",
        "backgroundColor": "#F8F8F8"
    }
}
4.在index中寫啟動界面
<template>
    <view class="container ">
        <text class="title">主頁,{{ title }}</text>
    </view>
</template>

<script>
export default {
    data() {
        return {
            title: 'Hello'
        };
    },
    onLoad() {},
    methods: {}
};
</script>

<style>
.container {
    width: 95%;
    margin: 0 auto;
    text-align: center;
}
.title {
    font-size: 36upx;
    color: #8f8f94;
}
</style>
5.在pages目錄下新建目錄ucenter與index并列,創(chuàng)建ucenter.vue和setting.vue,ucenter.vue中代碼如下
<template>
    <view class="content">
        <view>
            <text class="title">{{title}}的個人中心</text>
            <navigator url="setting" hover-class="navigator-hover">
                <button type="primary">個人設(shè)置<tton>
            </navigator>
        <view>
        <view>
</template>

<script>
    export default {
        data() {
            return {
                title: '26'
            }
        },
        onLoad() {

        },
        methods: {

        }
    }
</script>

<style>
    .content {
        text-align: center;
        height: 400upx;
    }
    .title {
        font-size: 36upx;
        color: #8f8f94;
    }
    
</style>
6.運行結(jié)果到Chrome然后調(diào)試為手機瀏覽狀態(tài),結(jié)果如下
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容