vux 组件打造手机端项目
其实,我用vux组件的过程是这样的,哇!太方便了!!功能好全!!太简单了!!然后,就各种“跳坑”。以下排坑环节。
1、安装vux:cnpm i -S vux; 比较顺利吧。
2、导入组件:
import {ViewBox, XHeader, Tabbar, TabbarItem} from 'vux'
export default {
name: 'app',
components: {ViewBox, XHeader, Tabbar, TabbarItem}
}
报错!原因是vux内部样式是用less写的,所以要先安装less-loader!
cnpm install less less-loader --save
3、使用组件
<view-box>
<x-header :left-options="{backText:''}" title="MACC3.0" :right-options="{showMore:'true'}" slot="header">
</x-header>
<div style="height:650px;"> </div>
<tabbar solt="bottom">
<tabbar-item show-dot>
<img slot="icon" src="./assets/home.png">
<span slot="label">首页</span>
</tabbar-item>
<tabbar-item badge="2">
<img slot="icon" src="./assets/msg.png">
<span slot="label">消息</span>
</tabbar-item>
<tabbar-item selected>
<img slot="icon" src="./assets/new.png">
<span slot="label">用户</span>
</tabbar-item>
</tabbar>
</view-box>
报错!原因是vux内部有i18n语言包组件,需要配置:
cnpm install vux-loader
webpack.dev.config中加入:
var VuxLoader=require('vux-loader')
baseWebpackConfig=VuxLoader.merge(baseWebpackConfig,{plugins:['vux-ui']})
view-box 页面容器,应该height:100%,所以,它的父级html, body, #app的height:100%;
可以导入vux的重置样式文件:
@import '~vux/src/styles/reset.less';
最后,是不是感觉还是不对劲儿,手机端!index.html 中加入:
<meta name="viewport" id="viewport" content="width=device-width, initial-scale=1">
小提示:webstorm写vue 空格总引发报错,很不爽。找到 webpack.base.config.js文件,注释掉这样就不会再报错了

好了,终于写好个模板例子,直接复制粘贴吧。。。
<template>
<div id="app">
<view-box>
<x-header :left-options="{backText:''}" title="MACC3.0" :right-options="{showMore:'true'}" slot="header" class="my-header">
</x-header> <scoller :lock-y="true">
<div class="tab">
<tab>
<tab-item selected>已发货</tab-item>
<tab-item>未发货</tab-item>
<tab-item>全部订单</tab-item>
</tab>
</div>
</scoller>
<swiper :list="imgData" v-model="swiperIndex" :loop="true">
</swiper>
<marquee class="my-marquee">
<marquee-item>Lorem dolor doloribus earum error ipsa.</marquee-item>
<marquee-item>totam vel Dignissimos labore quam voluptatum.</marquee-item>
<marquee-item>consectetur adipisicing elit. Aperiam culpa.</marquee-item>
<marquee-item>laudantium nesciunt obcaecati omnis similiqu.</marquee-item>
</marquee>
<panel :list="datalist"> </panel>
<tabbar solt="bottom" style="background-color:#ccc" class="my-header">
<tabbar-item show-dot>
<img slot="icon" src="./assets/home.png">
<span slot="label">首页</span>
</tabbar-item>
<tabbar-item badge="2">
<img slot="icon" src="./assets/msg.png">
<span slot="label">消息</span>
</tabbar-item>
<tabbar-item selected>
<img slot="icon" src="./assets/new.png">
<span slot="label">用户</span>
</tabbar-item>
</tabbar>
</view-box> <!--<router-view></router-view>-->
</div>
</template> <script>
import {ViewBox, XHeader, Tabbar, TabbarItem, Tab, TabItem, Scroller, Swiper, Marquee, MarqueeItem, Panel} from 'vux'
export default {
name: 'app',
components: {
ViewBox,
XHeader,
Tabbar,
TabbarItem,
Tab,
TabItem,
Scroller,
Swiper,
Marquee,
MarqueeItem,
Panel },
data () {
return {imgData: [{
url: 'javascript:',
img: 'https://static.vux.li/demo/1.jpg',
title: '送你一朵fua'
}, {
url: 'javascript:',
img: 'https://static.vux.li/demo/2.jpg',
title: '送你一辆车'
}, {
url: 'javascript:',
img: 'https://static.vux.li/demo/3.jpg',
title: '送你一次旅行'
}],
swiperIndex: 0,
datalist: [{
src: 'http://placeholder.qiniudn.com/60x60/3cc51f/ffffff',
title: '标题一',
desc: 'Lorem dolor doloribus earum error ipsa.quam quam quam',
url: '/component/cell'
}, {
src: 'http://placeholder.qiniudn.com/60x60/3cc51f/ffffff',
title: '标题二',
desc: 'totam vel Dignissimos labore similiqu quam quam quam voluptatum.',
url: {
path: '/component/radio',
replace: false
}
}, {
src: 'http://placeholder.qiniudn.com/60x60/3cc51f/ffffff',
title: '标题三',
desc: 'consectetur adipisicing elit. Aperiam similiqu similiqu similiqu culpa.',
url: {
path: '/component/radio',
replace: false
}
}, {
src: 'http://placeholder.qiniudn.com/60x60/3cc51f/ffffff',
title: '标题四',
desc: 'laudantium similiqu nesciunt similiqu obcaecati omnis similiqu.',
url: {
path: '/component/radio',
replace: false
}
}, {
src: 'http://placeholder.qiniudn.com/60x60/3cc51f/ffffff',
title: '标题五',
desc: 'laudantium similiqu nesciunt similiqu obcaecati omnis similiqu.',
url: {
path: '/component/radio',
replace: false
}
}, {
src: 'http://placeholder.qiniudn.com/60x60/3cc51f/ffffff',
title: '标题六',
desc: 'laudantium similiqu nesciunt similiqu obcaecati omnis similiqu.',
url: {
path: '/component/radio',
replace: false
}
}
]
}
}
}
</script> <style lang="less">
@import '~vux/src/styles/reset.less';
#app {
color:#fff;
height:100%;
.my-header{
position: fixed;
width: 100%;
z-index: 99;
}
.tab{
margin-top:46px;
}
}
html,body{
height:100%;
margin:0;
}
.my-marquee{
margin-top: 7px;
color:#000;
} view-box{
height:100%;
} </style>
vux 组件打造手机端项目的更多相关文章
- 【阿里云IoT+YF3300】14.阿里IoT Studio打造手机端APP
在上一篇<13.阿里云IoT Studio WEB监控界面构建>中,我们介绍了用阿里云IoT Studio(原Link Develop)可视化构建WEB界面程序.本篇文章将介绍用阿里云Io ...
- [js开源组件开发]-手机端照片预览组件
手机端照片预览组件 可怜的我用着华为3C手机,用别人现成的组件都好卡,为了适应我这种屌丝,于是自己简化写了一版的照片预览效果,暂时无缩放功能,以后可能有空再加吧,你也可以自己加下,这是个github上 ...
- vue3系列:vue3.0自定义弹框组件V3Popup|vue3.x手机端弹框组件
基于Vue3.0开发的轻量级手机端弹框组件V3Popup. 之前有分享一个vue2.x移动端弹框组件,今天给大家带来的是Vue3实现自定义弹框组件. V3Popup 基于vue3.x实现的移动端弹出框 ...
- PHP项目实现手机端和PC端的页面切换
目前访问页面的要切换成手机端和PC端,原理是通过对设备作出判断,显示不同的功能和页面. 如果手机端和PC端的功能结构不相同,一般会写两套系统,一套适用于PC端,一套适用于手机端. 如果功能相同,则只需 ...
- 项目ITP(四) javaweb http json 交互 in action (服务端 spring 手机端 提供各种工具类)勿喷!
前言 系列文章:[传送门] 洗了个澡,准备写篇博客.然后看书了.时间 3 7 分.我慢慢规律生活,向目标靠近. 很喜欢珍惜时间像叮当猫一样 正文 慢慢地,二维码实现签到将要落幕了.下篇文章出二维码实 ...
- 手机端 https://doc.vux.li/zh-CN/components/badge.html
https://doc.vux.li/zh-CN/components/badge.html 手机端前端框架
- 专注手机端前端界面开发的ui组件和js组合
frozenui一款腾讯开发的简化版Bootstrap,只用于手机端 http://frozenui.github.io/ https://github.com/frozenui/frozenui z ...
- 学习手机端的META差异,打造自己的移动网页
我们先来简单了解下meta标签:meta指元素可提供有关页面的元信息(meta-information),比如针对搜索引擎和更新频度的描述和关键词. 标签位于文档的头部,不包含任何内容. 标签的属性定 ...
- java 工作流项目源码 SSM 框架 Activiti-master springmvc 有手机端功能
即时通讯:支持好友,群组,发图片.文件,消息声音提醒,离线消息,保留聊天记录 (即时聊天功能支持手机端,详情下面有截图) 工作流模块---------------------------------- ...
随机推荐
- 201521123027 <java程序设计>第11周学习总结
1.本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多线程相关内容. 2.书面作业 1.互斥访问与同步访问 完成题集4-4(互斥访问)与4-5(同步访问) 1.1 除了使用synchro ...
- 数据库系统概论——Chap. 1 Introduction
数据库系统概论--Introduction 一.数据库的4个基本概念 数据(data):数据是数据库中存储的基本单位.我们把描述事物的符号记录称为数据.数据和关于数据的解释是不可分的,数据的含义称为数 ...
- Spring REST API + OAuth2 + AngularJS
http://www.baeldung.com/rest-api-spring-oauth2-angularjs 作者:Eugen Paraschiv 译者:http://oopsguy.com 1. ...
- 教你在Java接口中定义方法
基本上所有的Java教程都会告诉我们Java接口的方法都是public.abstract类型的,没有方法体的. 但是在JDK8里面,你是可以突破这个界限的哦. 假设我们现在有一个接口:TimeClie ...
- 使用gc、objgraph干掉python内存泄露与循环引用!
Python使用引用计数和垃圾回收来做内存管理,前面也写过一遍文章<Python内存优化>,介绍了在python中,如何profile内存使用情况,并做出相应的优化.本文介绍两个更致命的问 ...
- PuTsangTo-单撸游戏开发03 碰撞与跳跃瑕疵版
继续上一部分,游戏的定位是横版平台动作类游戏,所以得有跳跃动作,首先想到的就是物理引擎,不过在2D游戏里,仅为了角色的跳跃而引入物理引擎,目前想来有些不至于,仅使用cocos默认带有的碰撞系统也足够了 ...
- js中如何在一个函数里面执行另一个函数
1.js中如何在函数a里面执行函数b function a(参数c){ b(); } function b(参数c){ } 方法2: <script type="text/javasc ...
- tomcat部署在centos6.8上的乱码问题
web访问经常会莫名其妙的出现各种乱码问题.按照我自己的理解,设置一个charSet的过滤器,代码如下:import java.io.IOException; import javax.servlet ...
- Android打包版本号设置
之前没有设置过打包的命名,每次打包都是默认的"app-realease.apk",之后手动修改名字来显示出它是一个新版本. 晚上学习了如何配置打包名称,很简单,修改build.gr ...
- Next Greater Element I
You are given two arrays (without duplicates) nums1 and nums2 where nums1's elements are subset of n ...