如何优雅的使用vue+vux开发app

 我来答
就烦条0o
2016-07-15 · 知道合伙人软件行家
就烦条0o
知道合伙人软件行家
采纳数:33315 获赞数:46492
从事多年系统运维,喜欢编写各种小程序和脚本。

向TA提问 私信TA
展开全部
<!DOCTYPE html>
<html>
<head>
    <title>vue-vux</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--include Vux style-->
    // register components
    Vue.component("actionsheet", vuxActionsheet);
    Vue.component("address", vuxAddress);
    Vue.component("alert", vuxAlert);
    Vue.component("badge", vuxBadge);
    Vue.component("blur", vuxBlur);
    Vue.component("box", vuxBox);
    Vue.component("button-tab", vuxButtonTab);
    Vue.component("button-tab-item", vuxButtonTabItem);
    Vue.component("calendar", vuxCalendar);
    Vue.component("card", vuxCard);
    Vue.component("cell", vuxCell);
    Vue.component("checker", vuxChecker);
    Vue.component("checker-item", vuxCheckerItem);
    Vue.component("checklist", vuxChecklist);
    Vue.component("circle", vuxCircle);
    Vue.component("clocker", vuxClocker);
    Vue.component("color-picker", vuxColorPicker);
    Vue.component("confirm", vuxConfirm);
    Vue.component("countdown", vuxCountdown);
    Vue.component("countup", vuxCountup);
    Vue.component("date-formatter", vuxDateFormatter);
    Vue.component("datetime", vuxDatetime);
    Vue.component("dev-tip", vuxDevTip);
    Vue.component("dialog", vuxDialog);
    Vue.component("divider", vuxDivider);
    Vue.component("flexbox", vuxFlexbox);
    Vue.component("flexbox-item", vuxFlexboxItem);
    Vue.component("friendly-time", vuxFriendlyTime);
    Vue.component("group", vuxGroup);
    Vue.component("group-title", vuxGroupTitle);
    Vue.component("icon", vuxIcon);
    Vue.component("inline-calendar", vuxInlineCalendar);
    Vue.component("inline-desc", vuxInlineDesc);
    Vue.component("inview", vuxInview);
    Vue.component("loading", vuxLoading);
    Vue.component("masker", vuxMasker);
    Vue.component("number-roller", vuxNumberRoller);
    Vue.component("offcanvas", vuxOffcanvas);
    Vue.component("orientation", vuxOrientation);
    Vue.component("panel", vuxPanel);
    Vue.component("picker", vuxPicker);
    Vue.component("popup", vuxPopup);
    Vue.component("popup-picker", vuxPopupPicker);
    Vue.component("previewer", vuxPreviewer);
    Vue.component("progress", vuxProgress);
    Vue.component("qrcode", vuxQrcode);
    Vue.component("radio", vuxRadio);
    Vue.component("range", vuxRange);
    Vue.component("rater", vuxRater);
    Vue.component("scroller", vuxScroller);
    Vue.component("search", vuxSearch);
    Vue.component("selector", vuxSelector);
    Vue.component("shake", vuxShake);
    Vue.component("spinner", vuxSpinner);
    Vue.component("steps", vuxSteps);
    Vue.component("sticky", vuxSticky);
    Vue.component("swiper", vuxSwiper);
    Vue.component("swiper-item", vuxSwiperItem);
    Vue.component("switch", vuxSwitch);
    Vue.component("tab", vuxTab);
    Vue.component("tab-item", vuxTabItem);
    Vue.component("tabbar", vuxTabbar);
    Vue.component("tabbar-item", vuxTabbarItem);
    Vue.component("timeline", vuxTimeline);
    Vue.component("timeline-item", vuxTimelineItem);
    Vue.component("tip", vuxTip);
    Vue.component("toast", vuxToast);
    Vue.component("wechat-emotion", vuxWechatEmotion);
    Vue.component("x-button", vuxXButton);
    Vue.component("x-header", vuxXHeader);
    Vue.component("x-img", vuxXImg);
    Vue.component("x-input", vuxXInput);
    Vue.component("x-number", vuxXNumber);
    Vue.component("x-textarea", vuxXTextarea);
    </script>
</head>
<body style="margin-top: -1em;">
    <div id="app">
        <!-- <h1>Demo</h1>
        <p> -->
            <!-- 使用指令 v-link 进行导航。 -->
           <!--  <a v-link="{ path: '/' }">Register 1</a>
            <a v-link="{ path: '/reg2' }">Register 2</a>
            <a v-link="{ path: '/login' }">Login</a>
            <a v-link="{ path: '/address' }">Address</a>
        </p> -->
        <!-- 路由外链 -->
        <router-view></router-view>
    </div>
    <style type="text/css">
    .v-link-active {
        color: blue;
    }
    </style>
    <script type="text/javascript">
    var Reg1 = Vue.extend({
        template: 
            '<group v-if="show">' +
                '<x-header :left-options="{showBack: false}">注册</x-header>' +
                '<x-input :value.sync="user_name" placeholder="姓名"></x-input>' +
                '<calendar :value.sync="DOB" title="出生日期"></calendar>' +
                '<popup-picker title="性别" :data="gneder_list" :value.sync="gender"></popup-picker>'+
                '<x-button type="primary" style="margin-top: 20px;" @click="$router.go(\'/reg2\')">CONTINUE</x-button>' +
            '</group>',
        data: function() {
            return {
                show: true,
                user_name: "",
                DOB: "1986-12-07",
                gender: [],
                gneder_list: [["男", "女"]]
            }
        }
    });

    var Reg2 = Vue.extend({
        template: 
            '<group v-if="show">' +
                '<x-header>注册</x-header>' +
                '<x-input :value.sync="email" is-type="email" placeholder="邮箱"></x-input>' +
                '<x-input :value.sync="re_email" is-type="email" placeholder="确认邮箱"></x-input>' +
                '<x-input :value.sync="password" placeholder="密码" type="password"></x-input>' +
                '<x-button type="primary" style="margin-top: 20px;" @click="$router.go(\'/login\')">CONTINUE</x-button>' +
            '</group>',
        data: function() {
            return {
                show: true,
                user_name: "",
                DOB: "1986-12-07",
                gender: "",
                gneder_list: ["男", "女"]
            }
        }
    });

    var Login = Vue.extend({
        template: 
            '<group v-if="show">' +
                '<x-header>登录</x-header>' +
                '<x-input :value.sync="email" is-type="email" placeholder="邮箱"></x-input>' +
                '<x-input :value.sync="password" placeholder="密码" type="password"></x-input>' +
                '<x-button type="primary" style="margin-top: 20px;" @click="$router.go(\'/\')">CONTINUE</x-button>' +
            '</group>',
        data: function() {
            return {
                show: true
            }
        },
        methods: {

        }
    });

    var Address = Vue.extend({
        template: 
            '<group v-if="show">' +
                '<x-header>address demo</x-header>' +
                '<address :title="title" :value.sync="value" :list="addressData"></address>' +
                '<cell title="上面value值" :value="value | json"></cell>' +
                '<address :title="title2" :value.sync="value2" raw-value :list="addressData"></address>' +
                '<address title="二级省市" :value.sync="value3" raw-value :list="addressData"></address>' +
                '<x-button type="primary" @click="changeData">改变数据</x-button>' +
            '</group>',
        data: function() {
            return {
                show: true,
                title: '默认为北京',
                value: [],
                title2: '手动设定',
                value2: ['广东省', '深圳市', '南山区'],
                value3: ['海南省', '儋州市', '--'],
                addressData: addressData
            }
        },
        methods: {
            changeData() {
                this.value2 = ['430000', '430400', '430407']
            },
        }
    });

    var App = Vue.extend({});
    var router = new VueRouter();
    router.map({
        '/'/*'/reg1'*/: {
            component: Reg1
        },
        '/reg2': {
            component: Reg2
        },
        '/login': {
            component: Login
        },
        '/address': {
            component: Address
        }
    });
    router.start(App, '#app');
    </script>
</body>

</html>
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式