angular - 如何将 SDK 链接到 DevOps Hub 扩展中的索引
问题描述
我正在尝试为 devops 制作一个 Angular 集线器扩展。我的问题是我不知道如何引用 VSS.SDK.min ...我按照 microsoft 网站上的文档进行操作,但无法使其正常工作
我试图制作一个简单的 hello Angular 应用程序。
这是我的 vss-extension.json:
{
"manifestVersion": 1,
"id": "theId",
"publisher": "MyPublisherID",
"version": "1.0.11",
"name": "AngularTest",
"description": "A sample Visual Studio Services extension",
"public": false,
"categories": ["Azure Repos"],
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
}
],
"contributions": [
{
"id": "my-hub",
"type": "ms.vss-web.hub",
"targets": [
"ms.vss-code-web.code-hub-group"
],
"properties": {
"name": "AnguTest",
"uri": "dist/angularTest/index.html"
}
}
],
"files": [
{
"path": "dist/angularTest/index.html",
"addressable": true
},
{
"path": "node_modules/vss-web-extension-sdk/lib",
"addressable": true,
"packagePath": "lib"
}
]
}
这是我的Index.html:
<!doctype html>
<html lang="en">
<head>
<script src="lib/VSS.SDK.min.js"></script>
<script type="text/javascript">
VSS.init();
VSS.ready(function() {
document.getElementById("name").innerText = VSS.getWebContext().user.name;
});
</script>
<meta charset="utf-8">
<title>AngularTest</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
</script>
</head>
<body style="background-color: red">
<h1>Hello, <span id="name"></span></h1>
<app-root></app-root>
</body>
</html>
当我尝试这样做时,我收到 2 个错误:
- 加载资源失败:服务器以 404 () 状态响应 VSS.SDK.min.js
- index.html:6 Uncaught ReferenceError: VSS is not defined at index.html:6(正常,因为服务器找不到js文件)
我只想显示索引页面。在那之后我想我会没事的!
解决方案
只需将“node_modules\vss-web-extension-sdk\lib”复制到您的扩展基础文件夹即可。
推荐阅读
- javascript - Flask - Javascript 和 CSS 未正确呈现
- amazon-web-services - 通过 AWS Step Functions 调用 AWS Lambda?
- database - 如何在子查询(MariaDB)中使用主查询中的值
- css - 使用 CSS 禁用顶部菜单上的悬停效果
- wpf - VB.net 在单击按钮时使用 IDataErrorInfo 验证文本框
- angular - 有没有办法在 IntelliJ 的 karma.conf.js 中指定 Angular 配置?
- java - 标签设置为可见不显示
- python - 我们如何创建即使在系统关闭后仍能运行的 Python 程序
- sql - SQLite - 从表中选择 3 个条件并 GROPING BY
- android - 如果应用程序进程不存在,则 ACTION_NEW_OUTGOING_CALL 的 Android 广播接收器不起作用