Skip to content

Commit

Permalink
update: 2md
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenda-hub committed Jan 2, 2025
1 parent b526e99 commit d833856
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
4 changes: 2 additions & 2 deletions content/posts/django教程.md
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ listen 8081;

源由协议、域名和端口号组成, 例如

- http://127.0.0.1:8000
- ws://127.0.0.1:8000
- `http://127.0.0.1:8000`
- `ws://127.0.0.1:8000`

跨域请求: CORS是一种机制,允许服务器声明哪些源可以访问它的资源。这需要**服务器端的配置**
30 changes: 27 additions & 3 deletions content/posts/vue教程.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,40 @@ form
- 开发页面内组件
- 调用 API

## 动态更新

当 URL 路径变化时,Vue Router 会根据配置的路由规则,动态更新并渲染对应的组件到 `<router-view />`

## vue-router

```js
import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView
},
{
path: '/login',
name: 'login',
component: () => import('../views/LoginView.vue')
},
]
})

router.beforeEach((to, from, next) => {})
```
## 输入校验
- 前端获取后端规则:通过接口获取后端定义的验证规则,如密码、用户名格式等。
- 前端实时验证:使用 Vue 的表单绑定和计算属性,动态应用规则进行表单验证。
- 后端最终验证:即使前端验证通过,后端仍需要做最终验证,以确保数据符合要求并避免安全风险。
- 友好的错误反馈:前端根据后端返回的错误信息提供用户友好的提示
## 动态更新

当 URL 路径变化时,Vue Router 会根据配置的路由规则,动态更新并渲染对应的组件到 `<router-view />`
## 部署
Expand Down

0 comments on commit d833856

Please sign in to comment.