美文网首页
6. 多端开发之uni-app起步

6. 多端开发之uni-app起步

作者: 叶小慈呀 | 来源:发表于2019-03-24 13:59 被阅读0次
  • 1.在HBuilderX中新建uni-app


    01
  • 项目结构图


    02
  • 配置pages.json文件
{
    "pages": [
        {
            "path": "pages/index/index",
            "style": {
                "navigationBarTitleText": "主页"
            }
        },
        {
            "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/home.png",
                "selectedIconPath": "static/home-active.png",
                "text": "主页"
            },
            {
                "pagePath": "pages/ucenter/ucenter",
                "iconPath": "static/center.png",
                "selectedIconPath": "static/center-active.png",
                "text": "我的"
            }
        ]
    },
    "globalStyle": {
        "navigationBarTextStyle": "white",
        "navigationBarBackgroundColor": "#2F85FC",
        "backgroundColor": "#FFFFFF"
    }
}
  • 在pages中简单写一下index.vue和ucenter.vue
    index.vue
<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>

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>
  • 启动雷神模拟器,选择真机运行(快捷键crtl+r)


    03
  • 控制台显示


    04
  • 模拟器运行显示


    05

    注:可以运行到手机上,打开手机的开发者模式,进行USB调试

相关文章

网友评论

      本文标题:6. 多端开发之uni-app起步

      本文链接:https://www.haomeiwen.com/subject/afhuvqtx.html