uni-app初體驗及打包成apk

首先用HBuilderX新建建一個uni-app項目html

新建一個目錄ucenter,該目錄下新建兩個vue文件ucenter.vue和setting.vuevue

ucenter.vue

<template>
    <view class="container">
        <text>{{ name }}的我的中心</text>
        <navigator url="../ucenter/setting" hover-class="navigator-hover">
            <button type="default">設置</button>
        </navigator>
    </view>
</template>

<script>
export default {
    data() {
        return {
            name: '陶然然'
        };
    },
    onLoad() {},
    methods: {}
};
</script>

<style>
.container {
    width: 95%;
    margin: 0 auto;
    text-align: center;
}
</style>

setting.vue

<template>
    <view class="container">
        舉世無雙
    </view>
</template>

<script>
</script>

<style>
</style>

pages.json中的代碼以下

{
    "pages": [ //pages數組中第一項表示應用啓動頁,參考:https://uniapp.dcloud.io/collocation/pages
        {
            "path": "pages/index/index",
            "style": {
                "navigationBarTitleText": "uni-app"
            }
        }
        ,{
            "path" : "pages/ucenter/ucenter",
            "style" : {
                "navigationBarTitleText": "中心"
            }
        },
        {
            "path" : "pages/ucenter/setting",
            "style" : {
                "navigationBarTitleText": "我的設置"
            }
        }
    ],
       "tabBar": {
        "color": "#000000",
        "selectedColor": "#2F85FC",
        "backgroundColor": "#FFFFFF",
        "borderStyle": "black",
        "list": [
            {
                "pagePath": "pages/index/index",
                "iconPath": "static/book.png",
                "selectedIconPath": "static/book_no.png",
                "text": "主頁"
            },
            {
                "pagePath": "pages/ucenter/ucenter",
                "iconPath": "static/write.png",
                "selectedIconPath": "static/write_a.png",
                "text": "個人"
            }
        ]
    },
    "globalStyle": {
        "navigationBarTextStyle": "black",
        "navigationBarTitleText": "uni-app",
        "navigationBarBackgroundColor": "#F8F8F8",
        "backgroundColor": "#F8F8F8"
    }
}

目錄結構以下,而後運行到小程序模擬器中的微信開發者工具(前提是你電腦得裝有,否則檢測不到,其它也同樣,能夠到運行配置裏面點擊相應網址去官網下載)


運行結果以下

打包成apk安裝到手機

首先要登陸,沒有賬號能夠註冊,接着點擊運行—原生App-雲打包,配置完後點擊打包,首次打包,提示說appid不能爲空,跳轉出基礎配置頁面,點擊雲端獲取,接下來再次打包就能夠順利完成了git



安裝到手機的效果以下
github

github代碼
uni-app官網
阿里巴巴矢量圖標庫json

我的網站小程序

相關文章
相關標籤/搜索