我正在尝试创建扩展,它允许我打开工作项上下文菜单并查看新控件,当我将鼠标悬停在控件上时,将打开一个子菜单。就像“移动到迭代”和“模板”的工作方式一样。
这是我的 vss-extension.json 的贡献部分:
"contributions": [
{
"id": "releaseMenuAction",
"type": "ms.vss-web.action",
"description": "test",
"targets": [
"ms.vss-work-web.backlog-item-menu",
"ms.vss-work-web.work-item-context-menu"
],
"properties": {
"name": "releaseMenuAction",
"text": "Assign to release",
"title": "Assign to release",
"icon": "img/delivery_small.png",
"uri": "index.html"
}
}
]
这是 html 页面:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="sdk/VSS.SDK.min.js"></script>
</head>
<body>
<script>
VSS.init({ usePlatformScripts: true, usePlatformStyles: true, explicitNotifyLoaded: true });
// Use an IIFE to create an object that satisfies the IContributedMenuSource contract
var menuContributionHandler = (function () {
"use strict";
return {
getMenuItems: function (actionContext) {
var subMenus = [
{
text: "one",
action: function (actionContext) {
alert("one");
}
},
{
text: "two",
action: function (actionContext) {
alert("two");
}
}
];
return [
{
text: "Assign to release",
group: "actions",
icon: "img/delivery_small.png",
childItems: subMenus
}
];
}
};
}());
// Associate the menuContributionHandler object with the "releaseMenuAction" menu contribution from the manifest.
VSS.register("releaseMenuAction", menuContributionHandler);
</script>
</body>
</html>
我得到的结果只是在菜单中看到“分配释放”控件,但没有他的孩子。
我错过了什么?
谢谢。
@PatrickLu-MSFT 感谢您的回复。
我设法解决了这个问题。我在代码中遗漏了一行:
VSS.notifyLoadSucceeded();
这一行“告诉”扩展成功加载的 tfs。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句