目录
为梁园等地区用户提供了全套网页设计制作服务,及梁园网站建设行业解决方案。主营业务为网站设计、
成都做网站 、梁园网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
1. 自动导入 Vue3 APIs —— unplugin-auto-import/vite
2. v-model
2.1 相较于 Vue2,Vue3 做出了哪些变化?
2.2 绑定一个 v-model
2.2.1 父组件
2.2.2 子组件
2.3 绑定多个 v-model
2.3.1 父组件
2.3.2 子组件
2.4 v-model 中的自定义修饰符 modelModifiers
2.4.1 父组件
2.4.2 子组件
2.5 v-model 源码分析 / emit 源码分析
2.5.1 v-model 源码分析
2.5.2 emit 源码分析
1. 自动导入 Vue3 APIs —— unplugin-auto-import/vite
GitHub - antfu/unplugin-auto-import: Auto import APIs on-demand for Vite, Webpack and RollupAuto import APIs on-demand for Vite, Webpack and Rollup - GitHub - antfu/unplugin-auto-import: Auto import APIs on-demand for Vite, Webpack and Rollup https://github.com/antfu/unplugin-auto-import
Vue3 中的 APIs 无需导入,可直接使用
使用示例:
// 使用前
import { computed, ref } from 'vue'
const count = ref(0)
const doubled = computed(() =>count.value * 2)
// 使用后
const count = ref(0)
const doubled = computed(() =>count.value * 2)安装命令:
npm i -D unplugin-auto-import
vite 配置:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// 注意:不能缺少 /vite
import AutoImport from 'unplugin-auto-import/vite'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), AutoImport({
imports:['vue'],
dts:"src/auto-import.d.ts"
})]
})
2. v-model
v-model 是一个语法糖,通过 props + emit 组合而成
2.1 相较于 Vue2,Vue3 做出了哪些变化?
props:value ->modelValue;
emits:input ->update:modelValue;
v-bind 的 .sync 修饰符和组件的 model 选项已移除
新增 支持多个v-model
新增 支持自定义 修饰符 Modifiers
2.2 绑定一个 v-model
2.2.1 父组件
在父组件中引入子组件,并给子组件添加 v-model 的绑定值 show
注意:此处的 v-model 只有一个,所以后面不用跟具体的名字,比如 v-model:title
是否展示 -- {{ show }}
2.2.2 子组件
在子组件中定义 v-model 需要的 props:
如果没有定义名字(比如 v-model:title 表示有名字),则使用默认写法 —— modelValue
在子组件中定义 v-model 需要的 emits:
如果没有定义名字(比如 v-model:title 表示有名字),则使用默认写法 —— update:modelValue
关闭按钮
内容
2.3 绑定多个 v-model
2.3.1 父组件
在父组件中引入子组件,并给子组件添加 v-model 的绑定值 show
注意:此处的 v-model 有多个:
后面可以跟具体的名字,比如 v-model:title; 后面也可以不跟名字,使用默认值(只能有一个默认的 v-model) 是否展示 -- {{ show }} -- {{ title }}
2.3.2 子组件
在子组件中定义 v-model 需要的 props:
如果没有定义名字,则使用默认写法 —— modelValue 如果有名字(比如 v-model:title),则这么写 —— title 在子组件中定义 v-model 需要的 emits:
如果没有定义名字,则使用默认写法 —— emit('update:modelValue', false) 如果有名字(比如 v-model:title),则这么写 —— emit('update:title','双向绑定改变 title')
关闭按钮
内容
2.4 v-model 中的自定义修饰符 modelModifiers
添加到 v-model 后边的修饰符,将通过 props 中的 modelModifiers 提供给组件
举个栗子~
在父组件中,定义了 v-model:title.islang,islang 就是自定义修饰符 在子组件的 props 中,通过 titleModifiers 属性接收并判断 —— 用户是否使用了自定义修饰符 islang,该 props 返回布尔值
2.4.1 父组件
在父组件中,给 v-model 添加修饰符 .islang —— v-model:title.islang
是否展示 -- {{ show }} -- {{ title }}
2.4.2 子组件
在子组件中,使用 titleModifiers 接收 v-model 修饰符,并在更新 title 值时,使用 自定义修饰符,判断应该返回什么值
基本
文件
流程
错误
SQL
调试
请求信息 : 2026-05-20 22:12:36 HTTP/1.1 GET : /article/pgjdo.html 运行时间 : 1.9821s ( Load:0.0065s Init:1.3557s Exec:0.6105s Template:0.0093s ) 吞吐率 : 0.50req/s 内存开销 : 2,244.79 kb 查询信息 : 12 queries 5 writes 文件加载 : 36 缓存信息 : 0 gets 0 writes 配置加载 : 130 会话信息 : SESSION_ID=e3f5k7kusbv16u44baf0021762
/www/wwwroot/tsicrk.com/index.php ( 1.09 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/ThinkPHP.php ( 4.61 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Think.class.php ( 12.26 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Storage.class.php ( 1.37 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Storage/Driver/File.class.php ( 3.52 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Mode/common.php ( 2.82 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Common/functions.php ( 53.56 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Hook.class.php ( 4.01 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/App.class.php ( 13.49 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Dispatcher.class.php ( 14.79 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Route.class.php ( 13.36 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Controller.class.php ( 11.23 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/View.class.php ( 7.59 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/BuildLiteBehavior.class.php ( 3.68 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ParseTemplateBehavior.class.php ( 3.88 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ContentReplaceBehavior.class.php ( 1.91 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Conf/convention.php ( 11.15 KB ) /www/wwwroot/tsicrk.com/App/Common/Conf/config.php ( 2.14 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Lang/zh-cn.php ( 2.55 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Conf/debug.php ( 1.49 KB ) /www/wwwroot/tsicrk.com/App/Home/Conf/config.php ( 0.31 KB ) /www/wwwroot/tsicrk.com/App/Home/Common/function.php ( 3.33 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ReadHtmlCacheBehavior.class.php ( 5.62 KB ) /www/wwwroot/tsicrk.com/App/Home/Controller/ArticleController.class.php ( 6.02 KB ) /www/wwwroot/tsicrk.com/App/Home/Controller/CommController.class.php ( 1.60 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Model.class.php ( 60.11 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php ( 32.43 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php ( 16.74 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Cache.class.php ( 3.83 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Cache/Driver/File.class.php ( 5.87 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template.class.php ( 28.16 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template/TagLib/Cx.class.php ( 22.40 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Template/TagLib.class.php ( 9.16 KB ) /www/wwwroot/tsicrk.com/App/Runtime/Cache/Home/7540f392f42b28b481b30614275e4e55.php ( 17.71 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/WriteHtmlCacheBehavior.class.php ( 0.97 KB ) /www/wwwroot/tsicrk.com/ThinkPHP/Library/Behavior/ShowPageTraceBehavior.class.php ( 5.24 KB )
[ app_init ] --START-- Run Behavior\BuildLiteBehavior [ RunTime:0.000005s ] [ app_init ] --END-- [ RunTime:0.000033s ] [ app_begin ] --START-- Run Behavior\ReadHtmlCacheBehavior [ RunTime:0.000301s ] [ app_begin ] --END-- [ RunTime:0.000328s ] [ view_parse ] --START-- [ template_filter ] --START-- Run Behavior\ContentReplaceBehavior [ RunTime:0.000056s ] [ template_filter ] --END-- [ RunTime:0.000082s ] Run Behavior\ParseTemplateBehavior [ RunTime:0.006357s ] [ view_parse ] --END-- [ RunTime:0.006389s ] [ view_filter ] --START-- Run Behavior\WriteHtmlCacheBehavior [ RunTime:0.000166s ] [ view_filter ] --END-- [ RunTime:0.000181s ] [ app_end ] --START--
1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`pid`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( pid= ) [8] Undefined index: pid /www/wwwroot/tsicrk.com/App/Home/Controller/ArticleController.class.php 第 47 行. [8] Undefined index: db_host /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 120 行. [8] Undefined index: db_port /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 121 行. [8] Undefined index: db_name /www/wwwroot/tsicrk.com/ThinkPHP/Library/Think/Db.class.php 第 122 行.
1.9821s