1. 頁面跳轉后返回到頁面上方
~~~
router.afterEach((to,from,next) => {
window.scrollTo(0,0);
})
~~~
2. vue部署到apache后,刷新會報錯,需要修改路由重寫規則,讓他返回到index.html訪問自己的界面
```
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
```
## 跨域
### 出現背景
本地vue請求后端時采用代理,打包到線上后出現跨域post請求變成了option
### 解決方案
1. 引入qs模塊`yarn add qs`
2. 使用qs將對象序列化
```
import qs from "qs"
qs.stringify(formdata)
```
## 刷新后頁面404
### 出現背景
采用了history模式,上線后發現刷新頁面就會404
### 解決方案
將找不到資源的url(不是路徑不是文件)重定向到index.html
```
<rule name="blog">
<match url="^((?!(upload|admin|portal|api)).)*$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
```
- php
- 安全
- php7
- 特性
- 編譯安裝
- 源碼整體框架
- 基本變量
- thinkphp3.2.3
- thinkphp5.0
- thinkphp6.0
- laravel
- 配置
- 路由
- artisan控制臺
- eloquent
- tinker
- composer
- 加密解密
- 小知識點
- 數組
- string
- 代碼簡潔之道
- 編譯
- 語法糖
- lumen
- smarty
- 錯題集
- 算法及數據結構
- 線性表結構
- 插入排序
- 冒泡排序
- 數據庫
- mysql
- oracle
- PostgreSQL
- redis
- sqlserver
- 前端
- 備忘
- js
- nodejs
- vue
- css
- electron
- vue
- 語法糖
- colorui使用筆記
- 微信小程序
- 操作系統
- windows
- bat
- 快捷鍵
- linux
- sed
- 問題解決
- git
- docker
- docker-compose
- 正則表達式
- ps
- lua
- 協議相關
- 問題思索
- Golang
- 測試
- 讀取和寫入json配置文件
- 類
- 接口
- mod
- gin
- fyne
- 禪道二次開發
- 服務
- apache
- 漏洞配置
- http server優化
- nginx
- 安裝
- 面試題庫
- freeswitch