随笔分类 - 前端 / vue2
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document<
阅读全文
摘要:下载安装npm i vuex 搭建vuex环境 1.创建文件:src/store/index.js //引入Vue核心库 import Vue from 'vue' //引入Vuex import Vuex from 'vuex' //应用Vuex插件 Vue.use(Vuex) //准备actio
阅读全文
摘要:方式一 1.将bootstrap.min.css放入src下assets目录 2.app组件中引入样式 import '@/assets/bootstrap.min.css' 如果使用import引入,会严格检查,当字体文件不存在时,会报错 方式二 1.将第三方样式放入目录:public/css目录
阅读全文
摘要:安装JQuery npm install --save jquery 安装 layui npm install --save layui将 layui 的静态资源文件夹(layui)复制到 Vue 项目的 public 目录下。 在 Vue 项目的根目录下,public 文件夹是用来放置不需要被 W
阅读全文
摘要:案例:将子组件Student中的name传给父App组件 Student组件 <template> <div class="student"> <h3>学生姓名:{{name}}</h3> <h3>学校性别:{{sex}}</h3> <button @click="sendStuName">点我把学
阅读全文
摘要:<!-- ref属性 1.被用来给元素或子组件注册引用信息(id的替代者) 2.应用在html标签上获取的是真实的DOM元素,应用在组件标签上是组件实例对象 --> <template> <div id="app"> <h2 v-text="msg" ref="title" hh="哈哈"></h2
阅读全文
摘要:通过后端返回的具体值,前端可以映射想要的值 如:status状态值为0就是代办,为1就是处置,为2就是完成 <el-table-column label="工单状态" prop="status"> <template slot-scope="scope"> <span style="margin-l
阅读全文
摘要:async:表示函数是异步执行, await:表示当前函数先执行,执行完之后,再执行其他函数 await用于等待一个promise对象,它只能在async函数中使用. async函数,会返回一个Promise对象,可以用.then调用async函数中return的结果 async function
阅读全文
摘要:vue.config.js文件中 module.exports = { configureWebpack: { resolve: { alias: { 'assets': '@/assets', 'common': '@/common', 'components': '@/components',
阅读全文
摘要:通过vuecli3创建项目 vue create mall 新建远程仓库 终端中执行命令 git remote add origin git@github.com:xxx/mall.git git push -u origin main
阅读全文
摘要:安装 npm install axios --save axios基本使用 axios({ url: 'http://123.207.32.32:8000/home/multidata', method: 'get'//不写默认get方式 }).then(res => { console.log(r
阅读全文
摘要:示例:修改state中info对象的name值 state: { info: {id: 1003, name: "kobe" } } actions: {//异步请求、方法写在actions里 aUpdateInfo(context,value){//{commit,state} setTimeou
阅读全文
摘要:有时候,需要从store中获取一些state变化之后的数据,这是可以放入getters中 下面例子:获取年龄大于20的学生数据 注: getters默认是不能传递参数的,如果希望传递参数,那么只能让getters本身返回一个函数
阅读全文
摘要:通过mutations修改state状态 mutations中的方法必须是同步方法 this.$store.commit('mutations中的方法') const store = new Vuex.Store({ state: { counter: 100 }, mutations: { //方
阅读全文
摘要:安装 npm install vuex --save 创建store文件夹及index.js文件 import Vue from 'vue' import Vuex from 'vuex' //1.安装插件 Vue.use(Vuex) //2.创建对象 const store = new Vuex.
阅读全文
摘要:使用方式 路径前面加上~ import方式导入不需要加~
阅读全文
摘要:<template> <div class="tab-bar-item" @click="itemClick"> <div v-if="!isActive"><slot name="item-icon"></slot></div> <div v-else><slot name="item-icon-
阅读全文