内容字号:默认大号超大号

段落设置:段首缩进取消段首缩进

字体设置:切换到微软雅黑切换到宋体

vue.js代码开发最常见的功能集合

2018-08-04 18:24 出处:清屏网 人气: 评论(0

1:点击新增按钮跳出新页面

<span class="inquire" @click="addNew">新增</span>

在方法中,添加这个方法即可

addNew()
            {
                this.$router.push({ name: "newMember" });
            },

完整代码

<template>
<span class="inquire" @click="addNew">新增</span>
</template>

<script>
export default {
        data() {
            return {               
            }
        },
        methods: {

             addNew()
            {
                this.$router.push({ name: "newMember" });
            },
        }

    }
</script>

2:实现一个简单的搜索框

图片.png

<template>
     <div class="search">
          <mt-search v-model="value"  :result="filterResult"></mt-search>
       </div>  
</template>

3:点击开关按钮

图片.png

<template>
      <div class="chooseOne">
             <mt-switch v-model="value1" ></mt-switch>
           </div>
</template>

<script>
export default {
        data() {
            return {  
                 value1:false,
            }
        },
        methods: {

        }

    }
</script>

4:点击按钮,弹出提示弹框

按需引入弹框插件import {MessageBox} from 'mint-ui';

图片.png

<template>
      <button @click="goChongZhiPage">充 值</button>
</template>

<script>
    import {MessageBox} from 'mint-ui';
    
export default {
        data() {
            return {                
            }
        },
        methods: {
             // 跳转到充值页面
          goChongZhiPage ()
          {     
            MessageBox.confirm("",{
                    title: '提示',
                    message: '请先选择会员再进行充值',
                    showCancelButton: false
                })         
          },
        }
    }
</script>

5:Toast功能

点击按钮,有两秒钟的提示成功的信息,import { Toast } from 'mint-ui';导入Toast功能

图片.png

<template>
   <button @click="chongZhiForMember">充 值</button>
</template>
<script>
import { Toast } from 'mint-ui';
export default {
  data() {
    return { 
    };
  },
 
  methods: {
    chongZhiForMember()
            {
                 Toast({
                        message: '充值成功',
                        duration: 2000
                    });
            } 
  },
};
</script>

6:vue最简单的tab点击切换效果

图片.png

<template>
    <div>
        <div v-for="(list,index) in typeList" class="aa" :class="{ red:changeRed == index}" @click="change(index)">{{list.a}}</div>
    </div>
</template>

<script>
    /*import headerTo from "../common/headerTo";
    import { MessageBox, Toast, Field } from "mint-ui";
    import axios from "axios";
    import global from "../../../static/js/global";
    import config from "../../../static/js/config";
    import { error } from 'util';*/

    export default {
        data() {
            return {
                typeList: [
                    { "a": "增加积分" },
                    { "a": "扣除积分" },
                    { "a": "积分清零" },
                    { "a": "查看积分" },

                ],
                changeRed: -1
            }
        },
        methods: {
            change(index) {
                this.changeRed = index;
            }
        }

    }
</script>

<style>
    .aa {
        cursor: pointer;
        width: 24%;
        height: 40px;
        line-height: 40px;
        float: left;
        text-align: center;
        font-size: 16px;
        border: 1px solid #D6D6D6;
    }
    
    .red {
        color: red;
    }
</style>

7:提示弹框中带有若干行字

图片.png

<template>
    <div class="app">
    <span class="inquire" @click="submitOne">开通</span>
    </div>
</template>

<script>
    import { Field, MessageBox, Toast } from 'mint-ui';
    export default {
        data() {
            return {
            }
        },
        methods: {
            submitOne() {
                MessageBox.confirm("<div>王小婷(16834562345)是否</div><div>开通VIP3会员卡</div><div>会员卡号:YYK 1234 1234 09</div>").then(action => {
                    console.log(this.member);

                });
            },
        },

    }
</script>
<style scoped>
    .app {
        background: #F1F1F1;
        height: 17.78rem;
    }
    .inquire {
        font-size: 0.43rem;
    }
</style>
分享给小伙伴们:
本文标签: vue.js

相关文章

发表评论愿您的每句评论,都能给大家的生活添色彩,带来共鸣,带来思索,带来快乐。

CopyRight © 2015-2016 QingPingShan.com , All Rights Reserved.

清屏网 版权所有 豫ICP备15026204号