sharepoint - SPOnline:在我的 SPfx WebPart 中包含功能/资产部署后,我无法将其放在任何 SitePage 上
问题描述
我正在尝试向 SharePoint Online 上的 SPfx WebPart 项目添加一些配置功能。问题是,只要我将功能信息放入我的 package-solution.json,配置的列表就会正确部署,但我无法将 WebPart 本身添加到站点页面上。
我正在为 SharePoint Online 的 SPfx WebPart 项目使用 Visual Studio Code。我已经在我们公司的租户中部署了各种 WebPart 和扩展,但我对具有功能和资产的事物还很陌生。
我的 WebPart 需要两个特定列表,当添加到每个 [New] -> [App] 的站点内容时,它应该自行部署。因此,我在我的项目中添加了一个 elements.xml 和两个 schema-*.xml 文件,并修改了 package-solution.json 以将它们作为一项功能包含在内。
从那时起,列表正确部署到我添加应用程序的 SiteCollection 或子站点。但是(!)在编辑 SitePage 和添加 WebPart 时,WebPart 本身不会显示。它甚至不在您选择所需 WebPart 的弹出窗口中。
将应用程序添加到 SiteCollection 时也没有安装错误,当从 package-solution.json 中删除功能信息时,WebPart 运行良好。
我在这里,不知道出了什么问题,需要你的帮助。
包解决方案.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "sp-bookingtool-admin",
"id": "30d57d62-8319-4b29-b0f9-***********",
"version": "2.0.0.6",
"features": [
{
"title": "sp-bookingtool-admin-features",
"description": "asset-deployment-webpart-client-side-solution",
"id": "523fe887-ced5-4036-b564-***********",
"version": "2.0.0.6",
"assets": {
"elementManifests": [
"elements.xml"
],
"elementFiles": [
"schema-sessions.xml",
"schema-courses.xml"
]
}
}
]
},
"paths": {
"zippedPackage": "solution/sp-bookingtool-admin.sppkg"
}
}
元素.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance
CustomSchema="schema-sessions.xml"
FeatureId="00bfea71-de22-43b2-a848-***********"
Title="BookingTool-Sessions"
Description="BookingTool-Sessions"
TemplateType="100"
Url="Lists/BookingToolSessions">
</ListInstance>
<ListInstance
CustomSchema="schema-courses.xml"
FeatureId="00bfea71-de22-43b2-a848-***********"
Title="BookingTool-Courses"
Description="BookingTool-Courses"
TemplateType="100"
Url="Lists/BookingToolCourses">
</ListInstance>
</Elements>
两个 schema.xml 中的 1 个
<List xmlns:ows="Microsoft SharePoint" Title="BookingTool-Courses" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/BookingToolCourses" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<Fields>
<Field ID="{1e513910-8092-45f7-b996-***********}" Name="Text_1" Type="Text" DisplayName="Text_1" Group="" Required="TRUE"/>
<Field ID="{d82721d4-0b3c-48cf-9a24-***********}" Name="Text_2" Type="Text" DisplayName="Text_2" Group="" Required="TRUE"/>
</Fields>
<Views>
<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
<RowLimit Paged="TRUE">30</RowLimit>
<Toolbar Type="Standard" />
<ViewFields>
<FieldRef Name="LinkTitle"></FieldRef>
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="LinkTitle" />
</OrderBy>
</Query>
</View>
</Views>
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
</MetaData>
</List>
解决方案
感谢一位同事,我自己发现了错误。
出乎我的意料,ListInstances 中的“FeatureID”不是已开发功能的 GUID,而是您使用的 Listtemplate 的 ID,具体取决于“TemplateType”。
<ListInstance
CustomSchema="schema-sessions.xml"
FeatureId="00bfea71-de22-43b2-a848-c05709900100"
Title="BookingTool-Sessions"
Description="BookingTool-Sessions"
TemplateType="100"
Url="Lists/BookingToolSessions">
</ListInstance>
00bfea71-de22-43b2-a848-c05709900100是自定义列表的 ID, 100是该列表的模板类型。
推荐阅读
- javascript - “无法对未安装的组件执行 React 状态更新”错误
- java - MySQL TestContainers init-script 模式创建失败
- mysql - 为什么在插入过程中发生重复键错误时设置共享锁
- javascript - 简单的 PurgeCSS
- c - C - 单独的链式哈希表 - 输出和空间问题
- javascript - 连续显示两个 Div 列,这样它也可以与 AMP(加速移动页面)一起使用
- ruby-on-rails - 销毁方法:为 API 收集的数据传递参数
- windows - 如何访问 Windows Batch 中变量中的各个项目?
- python - 矩形在 Pygame 中不动
- python - 无法更改从 xslx 和 Pandas 读取的某些列的数据类型