
Vue
文章平均质量分 50
梦想退休的许小姐
这个作者很懒,什么都没留下…
展开
-
Vue · 设置本地代理
本地开发的时,在浏览器访问项目的地址为 localhost, 但是当我们需要对接第三方验证后又回到本地项目时,由于第三方的回跳地址为正式服的域名就会不成功。这个时候就需要把域名映射到本地项目的地址,可以通过修改host文件实现。1、本地安装Whistlew2 start启动后,添加rules:/(?:https|http):\/\/griddev.jiuqi.com.cn/(.*)/ http://127.0.0.1:9898/$12、谷歌浏览器安装Proxy SwitchyOmega扩展原创 2022-04-01 14:24:55 · 1664 阅读 · 1 评论 -
Vue · Table:手写横向竖向滚动表格,分页、条数设置
效果:<template> <div> <div class="pages-tables" :style="{ height: screeHeight + 'px' }"> <div class="table-header" :style="{ width: header.length * 150 + 'px' }"> <table border="0" cellspacing="0" cellpadding=原创 2022-02-16 17:21:05 · 1974 阅读 · 0 评论 -
Vue · Vux:Tabbar导航
参考Tabbar原创 2021-11-30 17:02:40 · 837 阅读 · 0 评论 -
Vue · 报错
错误提示:Uncaught SyntaxError: Unexpected token u in JSON at position 0某个地方用了JSON.parse,但是传入的参数不是一个合格的json字符串。解决:搜索一下,parse,解析前先判断一下parse前记得判断下错误提示:Duplicate keys detected: ‘0’. This may cause an update error.错误原因一个template中有两个一样的v-for<div class="in原创 2021-11-29 17:28:07 · 372 阅读 · 0 评论 -
Vue · @click点击事件:阻止事件冒泡、取消默认事件
一般情况下绑定事件方法的:<div class="parent-wrapper" @click="clickWrapper">点这里</div>阻止事件冒泡方法:<div class="parent-wrapper" @click.stop="clickWrapper">点这里</div>取消默认事件方法:<div class="parent-wrapper" @click.prevent="clickWrapper">点这里<原创 2021-11-29 17:21:39 · 3883 阅读 · 0 评论 -
Vue · 使用iconfont
App.vue<style lang="scss">@import "~@/assets/scss/iconfont";</style>.vue<i class="iconfont icon-wanggejuxing" style="font-size: 13px"></i>参考小程序 · 使用iconfont原创 2021-11-29 16:38:51 · 247 阅读 · 0 评论 -
Vue · 遮罩层:禁止滑动
弹出层时禁止页面滚动data() {return {myInfoShow:false},watch: {myInfoShow(val) {var mo = function(e){e.preventDefault();};if(val){document.body.style.overflow=’’;//出现滚动条document.removeEventListener(“touchmove”,mo,false);}else{document.body.style.overflow原创 2021-11-29 15:31:36 · 846 阅读 · 0 评论 -
Vue · 页面截图、canvas绘图插件:domtoimage
domtoimage参考原创 2021-11-29 14:34:57 · 2139 阅读 · 0 评论 -
Vue · ECharts
xAxis:{position: ‘top’} //让x轴在顶部yAxis: { inverse:true} //让Y轴数据逆向legend: {orient: ‘vertical’,x:‘right’, //可设定图例在左、右、居中y:‘center’, //可设定图例在上、下、居中padding:[0,50,0,0], //可设定图例[距上方距离,距右方距离,距下方距离,距左方距离]data: [‘直接访问’,‘微信’,‘百度’,‘其他文章’,‘网页’]原创 2021-11-29 13:57:04 · 343 阅读 · 0 评论 -
Vue · 拼接html,绑定点击事件
在vue 的html拼接在添加点击事件用原生的onclick来触发事件,将事件挂在window上原创 2021-11-29 10:13:17 · 3515 阅读 · 2 评论 -
Vue · 设置浏览器icon
在index.html中引入<link rel="icon" href="./static/favicon.png" type="image/x-icon">原创 2021-10-27 11:55:06 · 175 阅读 · 0 评论 -
Vue · for循环:遍历对象、遍历对象数组
Document <div id="app"> <!-- 对象遍历 --> <div v-for="(value, key, index) in object"> {{ index }}. {{ key }} - {{ value }} </div> <!-- 数组对象遍历 --> <div v-for=...原创 2021-10-20 22:07:34 · 3996 阅读 · 0 评论 -
Vue · 操作数组
方法一适用于数组就只有一组listData: [{name:“张三”,age:18}],//直接添加对象listData.sex=“男”123方法二适用于数组中有多组信息listData:[],list:[{“张三”,“李四”}]//比如想把另外一个数组中编列出来的值加入到这个数组中for (let index = 0; index < this.listlist.length; index++) {this.listData.push({ name: “” });thi原创 2021-10-20 22:02:55 · 315 阅读 · 0 评论 -
Vue · 回到页面的某个位置
<div ref="scrollContainer"></div>this.$nextTick(function(){ this.$refs.scrollContainer.scrollTop = 0;});注意:该方法 (this.$refs) 只能在 mounted 的状态之后使用。原创 2021-10-20 21:22:32 · 280 阅读 · 0 评论 -
Vue · scroll:监听滚动
滚动监听页面滚动在mounted中进行监听滚动:mounted () { window.addEventListener('scroll', this.scrollToTop)},在方法中定义监听滚动执行的方法:scrollToTop() { var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop; console.log(sc原创 2021-10-20 19:28:18 · 6217 阅读 · 0 评论 -
Vue · swiper、vue-awesome-swiper
1、安装swiper4npm install swiper vue-awesome-swiper --save或指定swiper3//直接安装版本3即可,自动会选择3.1.3版本cnpm i vue-awesome-swiper@3 -S//或者手动指定cnpm i vue-awesome-swiper@3.1.3 -S2、引入模块页面引入即可,没必要全局引入,很少所以页面都要使用轮播的。全局引入只会增加额外的加载缓存和加载速度。全局引入(两个版本没有差别)import Vue原创 2021-10-20 17:21:08 · 784 阅读 · 1 评论 -
Vue · font引入外部字体
方法一:1、下载所需要的字体,.ttf格式(测试字体)2、 src下新建css文件,文件夹中包含以下文件font.css @font-face { font-family: 'Gen2'; src: url('./GenJyuuGothicMonospaceHeavy2.ttf') format('truetype'); font-weight: normal; font-style: normal; font-size: 18px; }3、引入字原创 2021-10-20 15:32:51 · 791 阅读 · 0 评论 -
Vue · elementUI
el-dropdown修改鼠标划过样式.el-dropdown-menu__item:hover { background: none; font-weight: 500; color: rgba(19, 29, 23, 0.8);}注意:给el-dropdown-menu添加自定义类名new-drop如果css中编写不生效(需要重新定义一个style,不要写scope)注意new-drop类名如果没有scoped会全局生效,所以一定注意不能重名,否则各个组件之间会相互影响参考:原创 2021-10-20 11:27:47 · 490 阅读 · 0 评论 -
Vue · 浏览器history路由栈
history也没有直接清空路由栈的方法,所以只能手动清空路由栈,代码如下:let backlen=history.length-1;history.go(-backlen);这段代码大家都可以看懂,其实所谓的跳到A页面其实是回退到A页面,将history中的路由栈回退掉,简单还不容易出错,backlen的数值大家可以根据自己的需求减几;...原创 2021-09-13 14:27:25 · 3433 阅读 · 0 评论 -
Vue · watch监听
问题:父组件传到子组件的prop,在子组件监听不到变化 data: { a: 1, b: 2, c: 3, d: 4, e: { f: { g: 5 } } }, watch: { a: function (val, oldVal) { console.log('new: %s, old: %s', val, oldVal) }, // 方法名 b: 'someMe原创 2021-09-10 17:58:37 · 891 阅读 · 0 评论 -
Vue · textarea高度自适应
scrollHeight 是内容的滚动高度,包含没实现出来的offsetHeight 当前控件显示的高度,如果文字增多了,不做自适应,这个高度不变,scrolHeight变大,所以可以比较这两个值,修改textarea的高度后,offsetHeight也就变了。<template> <div> <div class="address-container"> <label>当前地址</label> <te原创 2021-09-10 17:40:55 · 1332 阅读 · 1 评论 -
Vue · 导航守卫:beforeRouteEnter、beforeRouteUpdate、beforeRouteLeave
const Foo = { template: `...`, beforeRouteEnter(to, from, next) { // 在渲染该组件的对应路由被 confirm 前调用 // 不!能!获取组件实例 `this` // 因为当守卫执行前,组件实例还没被创建 next(vm => { // 通过 `vm` 访问组件实例 }) }, beforeRouteUpdate(to, from, next) { // 在当前原创 2021-09-10 16:58:42 · 1868 阅读 · 0 评论 -
Vue · switch开关组件
Switch组件<template> <div> <span class="weui-switch" :class="{ 'weui-switch-on': isChecked }" :value="value" @click="toggle" style="position: relative" > <div v-if="isChecked &&a原创 2021-09-01 15:29:41 · 2331 阅读 · 1 评论 -
Vue · textarea解析换行符,文本中的URL可跳转
vue 解析 textarea 换行符如果使用文本域输入内容, 在输入内容之后 我们可能习惯性的会按一下回车换行 , 然后我们将内容保存给后台后台保存之后,当我们再次获取展示时,发现之前的换行符都没有了 。解决办法:在需要展示文本域的内容的盒子添加一个样式.textarea {white-space: pre-line;}.p{white-space: pre-line;}123{{row.ent_profile}}textarea输入的空格以及换行,如果不转换,那么换行跟空格原创 2021-08-30 13:50:39 · 2710 阅读 · 0 评论 -
Vue · 对css样式修改
{{info}} style样式动态绑定方法一:(1) html中: (2) data中:videoBox:{width:800,height:500,}(3)mounted中:mounted() {this.videoBox.width=this.refs.videoMa.offsetWidth;this.videoBox.height=this.refs.videoMa.offsetWidth;...原创 2021-07-26 17:38:34 · 2306 阅读 · 0 评论 -
Vue · 绑定class
vue动态绑定class的几种方式前端那点事 2018-10-30 17:03:27 83792 收藏 56分类专栏: vue 文章标签: vue 动态绑定class版权#####对象方法-最简单的绑定(这里的active加不加单引号都可以,以下也一样都能渲染):class="{ ‘active’: isActive }"1判断是否绑定一个active:class="{‘active’:isActive==-1}"或者:class="{‘active’:isActive==inde原创 2021-07-26 17:29:25 · 128 阅读 · 0 评论 -
vue打包到生产环境页面样式无效
生产环境打包上线时页面样式无效,但测试服务正常页面提示Resource interpreted as Stylesheet but transferred with MIME type application/x-css访问页面时css文件可以加载出来,但是样式无法生效测试:正式:对比发现css文件的Content-Type变为了application/octet-stream稍微了解一下,问题就知道出在哪里了application/octet-stream这是应用程序文件的默原创 2021-07-01 23:37:39 · 3478 阅读 · 1 评论 -
Vue · 视图不更新
1、使用this.$set(obj, key, value)/vue.set(obj, key, value)<script>export default { data() { return { student: { name: '张三', } } }, methods: { setMessage() { this.$set(this.student, 'age', 15) console.log(this.stu原创 2021-06-30 17:07:40 · 118 阅读 · 0 评论 -
Vue · 移动端打电话
方法一<a :href="'tel:' + 110" rel="external nofollow">拨打电话</a>方法二 <a @click="callPhone" rel="external nofollow">拨打电话</a> callPhone(){ window.location.href = 'tel://110' },原创 2021-06-30 16:50:06 · 392 阅读 · 0 评论 -
vue微信H5项目中遇到的问题
1.跳转页面,页面数据刷新路由不变化这种情况使用$route无法获取到当前页面路由传递的参数解决方案:通过window.location.href获取当前的url进行拼接跳转 this.$router.replace({path: "/pinPage?"+this.GetQueryString('type')});Methods:{ GetQ.........原创 2019-03-11 14:28:03 · 1551 阅读 · 0 评论