原创 Vue 中Axios的封裝使用

1、在src 目錄下創建request 文件夾,然後在裏面新建http.js和api.js文件, http.js 用於封裝 axios, api.js用來統一管理我們的接口。 安裝       npm i axios --save 在ht

原创 Vue中使用axios POST請求變成OPTIONS的解決辦法

POST請求變成OPTIONS 及報錯信息(跨域) 主要解決方案:使用qs.stringify 1、安裝qs npm install qs --save 2、axios配置和使用 在接口請求頁面引入安裝好的qs,如下圖: 引入完成之

原创 jQuery實現模糊搜索效果

使用jQuery中:contains選擇器實現模糊搜索、匹配關鍵字效果。 <div class="warp"> <div class="search_box"> <input type="text" p

原创 使用JS去除字符串中的空格

var str = ' 去除 字符串 內空 格 '; this.text = str.replace(/\s*/g,""); str.replace(/\s*/g,""); //去除字符串內所有的空格 str.replace(

原创 使用Vue判斷當前設備是PC還是移動端

判斷方法如下: // 添加判斷方法 isMobile() { this.flag = navigator.userAgent.match(

原创 Vue中filter使用及根據id刪除數組元素

先在methods下寫一個filter過濾的方法 unique(arr) { // 根據唯一標識orderId來對數組進行過濾 console.log(arr); const res = new Map(

原创 vue2.0使用http-proxy-middleware代理解決跨域的問題

現在項目中安裝 http-proxy-middleware 安裝方法如下: npm install --save-dev http-proxy-middleware 然後在config/index.js中配置http-proxy-midd

原创 Vue中$emit傳遞一個或多個參數

$emit傳遞一個參數時 子組件: this.$emit('closeChange',false); 父組件: <div @closeChange="closeCom($event)"></div> closeCom(msg) {

原创 Element-UI 中 Upload上傳組件的action使用問題

<el-upload class="avatar-uploader" v-loading="loading" element-loading-spinner="el-icon-loading" e

原创 linux系統下安裝npm的方法

curl --silent --location https://rpm.nodesource.com/setup_10.x | bash - yum install -y nodejs npm install -g cnpm --re

原创 常用表單及輸入框總結

Input輸入框 <input type="text" placeholder="文本輸入"> <input type="number" placeholder="數字輸入"> <input type="password" placeh

原创 video標籤在iOS上無法自動播放解決辦法

由於項目中的視頻較大所以使用了video.js,安裝方法如下: npm install video.js  使用方法在main.js中配置如下: import Video from 'video.js' import 'video.

原创 Vue3.x 打包前配置

在項目中新建 vue.config.js 文件(vue cli 3 配置文件),設置publicPath 然後 設置publicPath module.exports = { publicPath: process.env.N

原创 Vue3.x 設置瀏覽器動態 Title 方法

使用插件 vue-wechat-title 來實現 (我是剛升級的vue3.x,在安裝插件的時候遇到了各種問題,後來發現可能是因爲的我node版本太低了,然後就去升級了一下,就好了) Node版本要求: Vue CLI 需要 Node.j

原创 Vue3.x 項目搭建步驟

先查看vue-cli版本:npm install -g @vue/cli 安裝更新:npm install -g @vue/cli 搭建項目 1、創建新的項目 vue create hello-world // vue create +