vue笔记

1.样式加scoped属性的作用:

<style> 标签添加了 scoped 属性,只作用于当前组件中的元素,

2.如何更改第三方组件的样式:用/deep/

使用深度作用选择器/deep/,使用方式:将/deep/ + space空格 添加在第三方样式类的前面。如果是使用less语法的话,直接在第三方样式的最外一层添加一遍/deep/就可以了

例子:

html:

<div class="pop_choose_price">
    <van-collapse v-model="activeName" accordion>
        <van-collapse-item title="姓名分析 ¥588.00" name="1" class="gray" :class="{ current: activeName === '1' }">根据生辰八字,分析五行喜忌强弱、命格特点分析出阻碍运势的关键因素。</van-collapse-item>
    </van-collapse>
</div>

css:

.pop_choose_price {
    height: 300px;
    overflow-y: auto;
    /deep/ .van-cell__title {
        color: #e35c57;
        padding-left: 20px;
    }
    /deep/ .van-collapse-item__content {
        color: #333;
    }
    .gray {
        /deep/ .van-cell__title {
            position: relative;
            &::before {
                content: "";
                position: absolute;
                z-index: 2;
                left: -7px;
                top: 50%;
                transform: translateY(-50%);
                 18px;
                height: 18px;
                background: #dbd0bf;
                background-size: 15px 10px;
                border-radius: 50%;
            }
        }
    }
    .current {
        /deep/ .van-cell__title {
            position: relative;
            &::before {
                content: "";
                position: absolute;
                z-index: 2;
                left: -7px;
                top: 50%;
                transform: translateY(-50%);
                 18px;
                height: 18px;
            }
        }
    }
}

 3.Vue 设置去掉button默认背景色和阴影

background-color: unset;
        box-shadow: none !important;

本来是这样的,背景底色默认是红色

设置之后:

 4.vue返回上一级

 this.$router.go(-1)

运行vue文件:

node -v 检查版本号

安装依赖模块. 运行命令: "npm install".

npm install npm -g 升级版本

npm install -g @vue/cli

vue --version 检查版本

创建项目

vue create my-demo

vue ui  运行

lint 检查规范

build  打包

$emit 发送,$on接收,$off销毁

this.$bus.$emit("updataTitle", data.name);
created() {
        this.$bus.$on("updataTitle", name => {
            this.title = name;
        });
    },
    beforeDestroy() {
        this.$bus.$off("updataTitle");
    },
原文地址:https://www.cnblogs.com/huanghuali/p/11829418.html