From 4bf32f5e4e70842af0976120632b2d67bc36b580 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Fri, 26 Jul 2024 10:32:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(app.use):=20=E8=A1=A5=E5=85=85=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=B8=BA=20null=20=E7=A4=BA=E4=BE=8B=E5=8F=8A?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/CompForAppUse.uvue | 3 ++- main.uts | 8 +++++++- pages/app-instance/use/use.test.js | 8 +++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/components/CompForAppUse.uvue b/components/CompForAppUse.uvue index c57e228..5b43324 100644 --- a/components/CompForAppUse.uvue +++ b/components/CompForAppUse.uvue @@ -5,7 +5,8 @@ plugin2: {{ plugin2 }} plugin3: {{ plugin3 }} plugin4: {{ plugin4 }} - + + diff --git a/main.uts b/main.uts index eadb644..229c38e 100644 --- a/main.uts +++ b/main.uts @@ -269,7 +269,13 @@ export function createApp() { app.use(plugin4) app.use(function (app: VueApp, componentName: string, componentInstance: CreateVueComponent) { app.component(componentName, componentInstance) - }, 'CompForPlugin', CompForPlugin) + }, 'CompForPlugin1', CompForPlugin) + + app.use({ + install(app: VueApp, a: string | null, b: string | null) { + app.component('CompForPlugin2', CompForPlugin as CreateVueComponent) + } + }, null, null) app.config.globalProperties.globalPropertiesStr = 'default string' app.config.globalProperties.globalPropertiesNum = 0 diff --git a/pages/app-instance/use/use.test.js b/pages/app-instance/use/use.test.js index 0855413..4eeafcf 100644 --- a/pages/app-instance/use/use.test.js +++ b/pages/app-instance/use/use.test.js @@ -24,9 +24,11 @@ describe('app-instance', () => { 'plugin4: 通过 definePlugin + 函数方式创建的 plugin' ) - const compForPluginEl = await page.$('.component-for-plugin') - const compForPluginText = await compForPluginEl.text() - expect(compForPluginText).toBe('component for plugin') + const compForPluginEls = await page.$$('.component-for-plugin') + const compForPlugin1Text = await compForPluginEls[0].text() + expect(compForPlugin1Text).toBe('component for plugin') + const compForPlugin2Text = await compForPluginEls[1].text() + expect(compForPlugin2Text).toBe('component for plugin') } it('app.use options API', async () => { -- GitLab