ComponentRef

class ComponentRef<C> {
  get location(): ElementRef
  get injector(): Injector
  get instance(): C
  get hostView(): ViewRef
  get changeDetectorRef(): ChangeDetectorRef
  get componentType(): Type<any>
  destroy(): void
  onDestroy(callback: Function): void
}

描述

Represents an instance of a Component created via a ComponentFactory.
表示通过ComponentFactory创建的组件的实例。

ComponentRef provides access to the Component Instance as well other objects related to this Component Instance and allows you to destroy the Component Instance via the destroy method.

方法

  • get location(): ElementRef

Location of the Host Element of this Component Instance.
该组件实例的Host元素的位置。

  • get injector(): Injector

The injector on which the component instance exists.
组件实例所在的注入器

  • get instance(): C

The instance of the Component.
组件实例

  • get hostView(): ViewRef

The ViewRef of the Host View of this Component instance.
该组件实例的Host视图的ViewRef

  • get changeDetectorRef(): ChangeDetectorRef

The ChangeDetectorRef of the Component instance.
组件实例的ChangeDetectorRef。

  • get componentType(): Type

The component type.
组件类型

  • destroy(): void

Destroys the component instance and all of the data structures associated with it.
销毁组件实例和与之关联的所有数据结构。

  • onDestroy(callback: Function): void

Allows to register a callback that will be called when the component is destroyed.
允许注册在组件销毁时将被调用的回调。

<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://wixtoolset.org/schemas/v6/wxs"> <Package Id="AcmeCorp.QuickStartExample" Name="MyApp" Manufacturer="MyCompany" Version="1.0.0.0" InstallerVersion="600" Compressed="yes" InstallScope="perMachine"> <!-- 主程序文件 --> <File Source="MyApp.exe" /> <!-- 目录结构 --> <StandardDirectory Id="ProgramFiles64Folder"> <Directory Id="INSTALLDIR" Name="MyApp"> <Component> <File Source="MyApp.exe" /> </Component> </Directory> </StandardDirectory> <!-- 桌面快捷方式 --> <StandardDirectory Id="DesktopFolder"> <Component> <Shortcut Id="DesktopShortcut" Name="MyApp" Target="[INSTALLDIR]MyApp.exe" WorkingDirectory="INSTALLDIR"/> <RegistryValue Root="HKCU" Key="Software\MyCompany\MyApp" Name="DesktopShortcutInstalled" Type="integer" Value="1" KeyPath="yes"/> </Component> </StandardDirectory> <!-- 功能定义 --> <Feature Id="MainFeature" Title="Main Application" Level="1"> <ComponentRef Id="Component_INSTALLDIR" /> <ComponentRef Id="Component_DesktopFolder" /> </Feature> <!-- 平台条件:仅64位系统 --> <Condition Message="This installer requires a 64-bit version of Windows."> <![CDATA[Installed OR VersionNT64]]> </Condition> </Package> </Wix> 报错:D:\QuickStart>dotnet build 还原完成(0.4) QuickStart 失败,出现 2 错误 (1.6 秒) D:\QuickStart\Package.wxs(2): error WIX0199: The Wix element has an incorrect namespace of 'http://wixtoolset.org/schemas/v6/wxs'. Please make the Wix element look like the following: <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">. D:\QuickStart\Package.wxs(2): error WIX0199: The Wix element has an incorrect namespace of 'http://wixtoolset.org/schemas/v6/wxs'. Please make the Wix element look like the following: <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">. 在 2.2 秒内生成 失败,出现 2 错误 怎么解决,输出修改后的完整代码
07-29
若要使用 WiX 工具集创建第一个安装包,只需要一个文本编辑器和 .NET SDK。如果你有 Visual Studio 2022,则两者兼而有之。 打开命令提示符并执行以下步骤。 为您的第一个 WiX 项目创建一个新目录。 C:\> md C:\src\QuickStart cd C:\src\QuickStart 创建一个新的文本文件作为名为 QuickStart.wixproj 的 WiX 项目文件,其中包含以下内容。 快速入门.wixproj <Project Sdk="WixToolset.Sdk/6.0.0"> </Project> 创建一个名为 Package.wxs 的新 WiX 源文件,其中包含以下内容。 包.wxs <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> <Package Id="AcmeCorp.QuickStartExample" Name="QuickStart Example" Manufacturer="ACME Corp" Version="0.0.1"> <File Source="example.txt" /> </Package> </Wix> 创建一个名为 example.txt 的新文本文件,其中包含您想要的任何内容。 example.txt This is example.txt. It's just example data. 生成项目。 C:\src\快速入门> dotnet build 这是wix官方文档给出的教程,我将完全遵循这个教程来写,仅仅是wxs文件内容不同,以下是我的wxs文件内容: <?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://wixtoolset.org/schemas/v6/wxs"> <Package InstallerVersion="600" Compressed="yes" InstallScope="perMachine" Platform="x64" Manufacturer="MyCompany"/> <Product Id="*" Name="MyApp" Language="1033" Version="1.0.0.0"> <!-- 目录结构 --> <StandardDirectory Id="ProgramFiles64Folder"> <Directory Id="INSTALLDIR" Name="MyApp"> <Component> <File Source="MyApp.exe" /> </Component> </Directory> </StandardDirectory> <!-- 快捷方式 --> <StandardDirectory Id="DesktopFolder"> <Component> <Shortcut Id="DesktopShortcut" Name="MyApp" Target="[INSTALLDIR]MyApp.exe" WorkingDirectory="INSTALLDIR"/> <RegistryValue Root="HKCU" Key="Software\MyApp" Name="DesktopShortcutInstalled" Type="integer" Value="1" KeyPath="yes"/> </Component> </StandardDirectory> <!-- 添加主功能组件 --> <Feature Id="MainFeature" Title="Main Feature" Level="1"> <ComponentRef Id="ProductComponent" /> <!-- 需要为INSTALLDIR组件添加ID --> <ComponentRef Id="DesktopShortcutComponent" /> <!-- 需要为快捷方式组件添加ID --> </Feature> </Product> </Wix> 现在报错:D:\QuickStart>dotnet build 还原完成(0.3) QuickStart 失败,出现 1 错误 (1.5 秒) D:\QuickStart\Packge.wxs(24): error WIX0104: Not a valid source file; detail: The 'Product' start tag on line 10 position 4 does not match the end tag of 'StandardDirectory'. Line 24, position 7.,请你帮我解决,输出修改过后的完整代码,不要省略代码
07-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值