随笔分类 - VUE
摘要:父级调用子级 父级: <script> this.$refs.child.load(); 或 this.$refs.one.load(); </script> 子级: <Hello ref="child"/> 或 <Hello ref="one"/> 子级调用父级 : 父级一定要加事件监听 v-on
阅读全文
摘要:在根目录下创建 vue.config.js 文件 。 即可 vue.config.js : // vue.config.js 配置说明 //官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions // 这里只列一
阅读全文
摘要:因为字符串模板不能被vue所渲染,所以这种方式行不通。 可采用组件的方式 父组件 <template> <div id="app"> <My v-for="(v,index) in commentList" :key="index" :commentId="v"/> </div> </templat
阅读全文
摘要:'/api': { target: 'http://localhost:8088/', //这里后台的地址模拟的;应该填写你们真实的后台接口 changOrigin: true, //允许跨域 pathRewrite: { /* 重写路径,当我们在浏览器中看到请求的地址为:http://localh
阅读全文
摘要:需要通过 require包裹 <template> <div> {{user.username}}: <img :src="user.avatar" class="avatar"> </div> </template> <script> export default { name: 'Persona
阅读全文
摘要:<div :class="{active:item.index==1}" > </div>
阅读全文
摘要:一,在 created中 注册 页面刷新和关闭事件 created() { window.addEventListener('beforeunload', e => this.test(e)) } 二,事件,将你的逻辑方法加进去 methods: { test(e) { console.log('刷
阅读全文
摘要:router.beforeEach((to, from, next) => { if(to.path!='/login' && localStorage.token==undefined){ next('/login') return } next() })
阅读全文
摘要:第一种,只引入单个图片,这种引入方法在异步中引入则会报错。 比如需要遍历出很多图片展示时 <image :src = require('图片的路径') /> 第二种,可引入多个图片,也可引入单个图片。 vuelic3版本没有static文件夹。可将静态图片存放到public目录下,直接引入即可 <i
阅读全文
摘要:/* 为对应的路由跳转时设置动画效果 */ <transition name="fade"> <router-view /> </transition> .fade-enter-active, .fade-leave-avtive { transition: opacity 1s } .fade-e
阅读全文
摘要:<img class="headImg" :src="require('../../assets/uploads/'+headImg)" alt="图片资源">
阅读全文
摘要:<div class="right userPicture" :style="[{'background':`url(${userImg}) no-repeat center`},{'background-size': 'cover'}]"></div>
阅读全文
摘要:一定要将静态资源引入 【 require("@/assets/") 】,绑定到 模型绑定的:src 数据中 动态的数据才能有效 <template> <div> <el-card class="box-card"> <div slot="header" class="clearfix"> <span
阅读全文
摘要:直接上代码。 <template> <div> <el-upload action="http://localhost:3000/picture" :http-request = "getimages" :before-upload = "beforeUp" :headers="headers" l
阅读全文
摘要:一,只有在上传文件之前的钩子函数中才可以获得最初的文件(文件本身的二进制形式),用以以上传服务器。 还需要使用formdata来承载数据,便于接收 <template> <div> <el-upload action="http://localhost:3000/picture" :http-req
阅读全文
摘要:<template> <div> <el-upload action="http://localhost:3000/picture" :headers="headers" list-type="picture-card" :on-preview="handlePictureCardPreview"
阅读全文