vue使用mammoth案例_vue快速入门的三个小实例

本文是关于Vue.js的入门教程,通过三个实际的小项目——选项卡、统计总价和文字编辑,帮助读者逐步了解和掌握Vue的基础用法。文章详细介绍了每个实例的实现原理和代码,适合已具备HTML、CSS和JavaScript基础的读者学习。通过实践,读者可以更好地理解和运用Vue的数据绑定、事件处理等核心特性。
摘要由CSDN通过智能技术生成

1.前言

用vue做项目也有一段时间了,之前也是写过关于vue和webpack构建项目的相关文章,大家有兴趣可以去看下webpack+vue项目实战(一,搭建运行环境和相关配置)(这个系列一共有5篇文章,这是第一篇,其它几篇文章链接就不贴了)。但是关于vue入门基础的文章,我还没有写过,那么今天就写vue入门的三个小实例,这三个小实例是我刚接触vue的时候的练手作品,难度从很简单到简单,都是入门级的。希望能帮到大家更好的学习和了解vue,也是让自己能够复习一下vue。如果发现文章写得有什么不好,写错了,或者有什么建议!欢迎大家指点迷津!

1.本篇文章使用的vue版本是2.4.2,大家要注意版本问题

2.现在我也是假设您有基础的html,css,javascript的知识,也已经看过了官网的基本介绍,对vue有了一个大概的认识了,了解了常用的vue指令(v-model,v-show,v-if,v-for,v-on,v-bind等)!如果刚接触前端的话,你看着文章可能会蒙圈,建议先学习基础,掌握了基础知识再来看!

3.下面的实例,建议大家边看文章边动手做!这样思路会非常清晰,不易混乱!也不会觉得文章长!如果只看文章,你可能未必会看完,因为文章我讲得比较细,比较长!

4.这几个实例,摘自我自己的平常练习的项目,代码已经提到github上面了(vue-demos)。欢迎大家star。!

2.什么是vue

vue是现在很火的一个前端MVVM框架,它以数据驱动和组件化的思想构建,与angular和react并称前端三大框架。相比angular和react,vue更加轻巧、高性能、也很容易上手。大家也可以移步,看一下vue的介绍和核心功能官网介绍。简单粗暴的理解就是:用vue开发的时候,就是操作数据,然后vue就会处理,以数据驱动去改变DOM(不知道有没有理解错,理解错了指点下)。

下面就是一个最简单的说明例子

代码如下

html

{ { message }}

js

new Vue({

el: '#app',

data: {

message: 'Hello Vue!'

}

})

相信也不难理解,就是input绑定了message这个值,然后在input修改的时候,message就改了,由于双向绑定,同时页面的html({ { message }})进行了修改!

好,下面进入例子学习!

3.选项卡

运行效果

原理分析和实现

这个很简单,无非就是一个点击切换显示而已。但是大家也要实现。如果这个看明白了,再看下面两个!这个实例应该只是一个热身和熟悉的作用!

这个的步骤只有一步,原理也没什么。我直接在代码打注释,看了注释,大家就明白了!

完整代码

Title

body{

font-family:"Microsoft YaHei";

}

#tab{

width: 600px;

margin: 0 auto;

}

.tab-tit{

font-size: 0;

width: 600px;

}

.tab-tit a{

display: inline-block;

height: 40px;

line-height: 40px;

font-size: 16px;

width: 25%;

text-align: center;

background: #ccc;

color: #333;

text-decoration: none;

}

.tab-tit .cur{

background: #09f;

color: #fff;

}

.tab-con div{

border: 1px solid #ccc;

height: 400px;

padding-top: 20px;

}

html

css

javascript

vue

html

css

javascript

vue

new Vue({

el: '#tab',

data: {

curId: 0

},

computed: {},

methods: {},

mounted: function () {

}

})

4.统计总价

运行效果

原理分析和实现

首先,还是先把布局写好,和引入vue,准备vue实例,这个不多说,代码如下

Title

.fl{

float: left;

}

.fr{

float: right;

}

blockquote, body, dd, div, dl, dt, fieldset, form, h1, h2, h3, h4, h5, h6, img, input, li, ol, p, table, td, textarea, th, ul {

margin: 0;

padding: 0;

}

.clearfix{

zoom: 1;

}

.clearfix:after {

clear: both;

}

.clearfix:after {

content: '.';

display: block;

overflow: hidden;

visibility: hidden;

font-size: 0;

line-height: 0;

width: 0;

height: 0;

}

a{

text-decoration: none;

color: #333;

}

img{vertical-align: middle;}

.page-shopping-cart {

width: 1200px;

margin: 50px auto;

font-size: 14px;

border: 1px solid #e3e3e3;

border-top: 2px solid #317ee7; }

.page-shopping-cart .cart-title {

color: #317ee7;

font-size: 16px;

text-align: left;

padding-left: 20px;

line-height: 68px; }

.page-shopping-cart .red-text {

color: #e94826; }

.page-shopping-cart .check-span {

display: block;

width: 24px;

height: 20px;

background: url("shopping_cart.png") no-repeat 0 0; }

.page-shopping-cart .check-span.check-true {

background: url("shopping_cart.png") no-repeat 0 -22px; }

.page-shopping-cart .td-check {

width: 70px; }

.page-shopping-cart .td-product {

width: 460px; }

.page-shopping-cart .td-num, .page-shopping-cart .td-price, .page-shopping-cart .td-total {

width: 160px; }

.page-shopping-cart .td-do {

width: 150px; }

.page-shopping-cart .cart-product-title {

text-align: center;

height: 38px;

line-height: 38px;

padding: 0 20px;

background: #f7f7f7;

border-top: 1px solid #e3e3e3;

border-bottom: 1px solid #e3e3e3; }

.page-shopping-cart .cart-product-title .td-product {

text-align: center;

font-size: 14px; }

.page-shopping-cart .cart-product-title .td-check {

text-align: left; }

.page-shopping-cart .cart-product-title .td-check .check-span {

margin: 9px 6px 0 0; }

.page-shopping-cart .cart-product {

padding: 0 20px;

text-align: center; }

.page-shopping-cart .cart-product table {

width: 100%;

text-align: center;

font-size: 14px; }

.page-shopping-cart .cart-product table td {

padding: 20px 0; }

.page-shopping-cart .cart-product table tr {

border-bottom: 1px dashed #e3e3e3; }

.page-shopping-cart .cart-product table tr:last-child {

border-bottom: none; }

.page-shopping-cart .cart-product table .product-num {

border: 1px solid #e3e3e3;

display: inline-block;

text-align: center; }

.page-shopping-cart .cart-product table .product-num .num-do {

width: 24px;

height: 28px;

display: block;

background: #f7f7f7; }

.page-shopping-cart .cart-product table .product-num .num-reduce span {

background: url("shopping_cart.png") no-repeat -40px -22px;

display: block;

width: 6px;

height: 2px;

margin: 13px auto 0 auto; }

.page-shopping-cart .cart-product table .product-num .num-add span {

background: url("shopping_cart.png") no-repeat -60px -22px;

display: block;

width: 8px;

height: 8px;

margin: 10px auto 0 auto; }

.page-shopping-cart .cart-product table .product-num .num-input {

width: 42px;

height: 28px;

line-height: 28px;

border: none;

text-align: center; }

.page-shopping-cart .cart-product table .td-product {

text-align: left;

font-size: 12px;

line-height: 20px; }

.page-shopping-cart .cart-product table .td-product img {

border: 1px solid #e3e3e3;

margin-right: 10px; }

.page-shopping-cart .cart-product table .td-product .product-info {

display: inline-block;

vertical-align: middle; }

.page-shopping-cart .cart-product table .td-do {

font-size: 12px; }

.page-shopping-cart .cart-product-info {

height: 50px;

line-height: 50px;

background: #f7f7f7;

padding-left: 20px; }

.page-shopping-cart .cart-product-info .delect-product {

color: #666; }

.page-shopping-cart .cart-product-info .delect-product span {

display: inline-block;

vertical-align: top;

margin: 18px 8px 0 0;

width: 13px;

height: 15px;

background: url("shopping_cart.png") no-repeat -60px 0; }

.page-shopping-cart .cart-product-info .product-total {

font-size: 14px;

color: #e94826; }

.page-shopping-cart .cart-product-info .product-total span {

font-size: 20px; }

.page-shopping-cart .cart-product-info .check-num {

color: #333; }

.page-shopping-cart .cart-product-info .check-num span {

color: #e94826; }

.page-shopping-cart .cart-product-info .keep-shopping {

color: #666;

margin-left: 40px; }

.page-shopping-cart .cart-product-info .keep-shopping span {

display: inline-block;

vertical-align: top;

margin: 18px 8px 0 0;

width: 15px;

height: 15px;

background: url("shopping_cart.png") no-repeat -40px 0; }

.page-shopping-cart .cart-product-info .btn-buy {

height: 50px;

color: #fff;

font-size: 20px;

display: block;

width: 110px;

background: #ff7700;

text-align: center;

margin-left: 30px; }

.page-shopping-cart .cart-worder {

padding: 20px; }

.page-shopping-cart .cart-worder .choose-worder {

color: #fff;

display: block;

background: #39e;

width: 140px;

height: 40px;

line-height: 40px;

border-radius: 4px;

text-align: center;

margin-right: 20px; }

.page-shopping-cart .cart-worder .choose-worder span {

display: inline-block;

vertical-align: top;

margin: 9px 10px 0 0;

width: 22px;

height: 22px;

background: url("shopping_cart.png") no-repeat -92px 0; }

.page-shopping-cart .cart-worder .worker-info {

color: #666; }

.page-shopping-cart .cart-worder .worker-info img {

border-radius: 100%;

margin-right: 10px; }

.page-shopping-cart .cart-worder .worker-info span {

color: #000; }

.choose-worker-box {

width: 620px;

background: #fff; }

.choose-worker-box .box-title {

height: 40px;

line-height: 40px;

background: #F7F7F7;

text-align: center;

position: relative;

font-size: 14px; }

.choose-worker-box .box-title a {

display: block;

position: absolute;

top: 15px;

right: 16px;

width: 10px;

height: 10px;

background: url("shopping_cart.p

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值