原创 實現未登錄跳轉回login頁

問題:未登陸直接輸入url:地址進入網站 vue項目實例: 一,設置router 1.首先配置路由 /src/router/index.js文件 import Vue from 'vue' import Router from '

原创 下載webpack插件時出現”Unexpected end of JSON input while parsing near”的錯誤

問題:按照官網配置webpack,npm install卻提示有錯誤提示”Unexpected end of JSON input while parsing near”的錯誤 解決:。 1,解決方案爲:清除緩存。 運行 npm

原创 Object.assign()及深拷貝

語法: Object.assign(target, …sources) target: 目標對象,sources: 源對象 用於將所有可枚舉屬性的值從一個或多個源對象複製到目標對象。它將返回目標對象。 const target =

原创 element導航菜單v-for循環數據後摺疊菜單欄時有下拉菜單的文字不隱藏

<el-menu default-active="1-4-1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" :collapse="is

原创 麪包屑實現 vue

麪包屑有兩種:一種是不帶動態參數,一種是需要攜帶動態參數跳轉的 一,不帶動態參數: 1,通過路由元meta實現,在每個需要麪包屑的頁面路由中固定寫好 如: router.js const router = new Router({

原创 vue mock數據引入本地json

作用:mock數據實現前端不依賴後臺接口開發 步驟: 1.npm install mockjs --save-dev 2.目錄 3.在src目錄下創建mock文件 index.js import Mock from 'mockj

原创 es6新增的常用的數組方法及字符串方法

一數組方法 1.forEach方法 let arr = ['a', 'b', 'c', 'd'] arr.forEach(function (val, idx, arr) { console.log(val + ', in

原创 vue重置data數據及element表單的重置出現自動驗證問題

逐個賦值 Object.assign(this.$data, this.$options.data()) this.data獲取當前狀態下的datathis.data 獲取當前狀態下的data this.data獲取當前狀

原创 vue項目實現代碼統一風格

問題:由於每個人的IDE格式化不一致,導致提交的代碼格式各異,在有衝突時可能會出現整個文件的衝突 解決: 1,在創建vue項目時添加eslint或者已有項目再單獨添加eslint 再pack.json裏 "scripts": {

原创 window location href跳轉地址時直接在當前地址後出現

問題:修改ip的接口成功後需要跳轉修改後的ip地址 失敗的代碼: this.$axios.get(url).then(res=>{ let path=res.ip+window.location.pathname window.l

原创 vue 三層對象的渲染 頁面正確顯示但console報錯error in render : 'typeerror':cannot read property 'path' of undefined

問題報錯: error in render : ‘typeerror’:cannot read property ‘path’ of undefined vue 三層對象的渲染(Splash.a.b) 例如:渲染的組件爲Splas

原创 v-model 雙向數據綁定原理理解

vue 同通過Object.defineProperty( )數據劫持方法裏的get,set屬性來監聽data裏的數據變化 一,先熟悉下Object.defineProperty( )及其屬性get,set 通過以下代碼就能理解

原创 element-ui中for循環或者table遍歷select且賦默認值

解決:把 v-model 的值加到循環數組中去,爲每個 select 設置了單獨的 v-model 變量值,對數據提前加工一下 直接上代碼: <template> <div v-for='(val,index) in data'>

原创 瀏覽器設置跨域

一,Mac下chrome瀏覽器跨域 在終端中輸入以下命令(yourname是自己本機用戶名) open -n /Applications/Google\ Chrome.app/ --args --disable-web-secur

原创 前端處理下載

一,後端文件流的形式(優點:簡單) url=拼接的url(接口url+param參數) 1,window.open(url) 缺陷:有被攔截的可能 2.利用a標籤download屬性實現下載,href爲url 3.利用from實現