# git_testvue
**Repository Path**: pen-seven/git_testvue
## Basic Information
- **Project Name**: git_testvue
- **Description**: vuewenjian
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2023-10-23
- **Last Updated**: 2023-11-10
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## ref 属性
1.被用来给元素或子组件注册引用信息(id 的替代者) 2.应用在 html 标签上获取的是真实 DOM 元素,应用在组件标签上是组件实例对象(vc) 3.使用方法:
打标识:
或
获取:this.$ref.xxx
## 配置项 props
功能:让组件接受外部传归来的数据
(1).传入数据:
(2).接收数据
第一种方式(只接收)
props:['name']
第二种方式(限制类型)
props:{name:String}
第三种方式(限制类型,限制必要性,指定默认值)
props:{
name:{type:String,required:true,default:'LaoWang'}
}
备注:props 是只读,Vue 底层会监测你对 props 的修改,修改了会被警告
若业务需求修改,请复制 props 中内容到 data 中一份,然后修改 data 中数据
## mixin(混入)
功能:可以把多个组件公用的配置提取成一个混入对象
使用方式:
一、定义混合
export const hunhe={
data(){……},
methods:{……},
…………
}
二、使用混入
全局混入:Vue.mixin(xxx)
局部混入:先import再mixins:['xxx','xxx',...]
## 插件
1. 功能:用于增强 Vue
2. 本质:包含 install 方法的一个对象,install 的第一个参数是 Vue,第二个以后的参数是插件使用者传递的数据。
3. 定义插件:
```js
对象.install = function (Vue, options) {
// 1. 添加全局过滤器
Vue.filter(....)
// 2. 添加全局指令
Vue.directive(....)
// 3. 配置全局混入(合)
Vue.mixin(....)
// 4. 添加实例方法
Vue.prototype.$myMethod = function () {...}
Vue.prototype.$myProperty = xxxx
}
```
4. 使用插件:`Vue.use()`
## scoped 样式
1. 作用:让样式在局部生效,防止冲突。
2. 写法:`