WinJS 有 #DEBUG 或 #RELEASE 指令吗? [英] WinJS are there #DEBUG or #RELEASE directives?
本文介绍了WinJS 有 #DEBUG 或 #RELEASE 指令吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在使用发布版与调试版时排除一些代码.基本上我有一个内部管理部分用于测试,我不会偶然将其放入应用程序商店:)
理想情况下,我只能做这样的事情:
#IF DEBUG<div id="appBar" data-win-control="WinJS.UI.AppBar"><button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'cmdAdmin', label:'Admin', section:'global' }">按钮>
#万一
解决方案
参见 此处.有一个 nuget 包 here 无需直接将代码添加到您的项目即可启用它.拥有它后,您只需执行以下操作:
如果(Debug.isDebugBuild){
以下是使用 nuget 包时不需要的完整代码:
(函数(){严格使用";if (Debug.hasOwnProperty("isDebugBuild")) {返回;}var thisPackage = Windows.ApplicationModel.Package.current,installedPath = thisPackage.installedLocation.path;if (typeof installedPath === "string") {if (installedPath.match(/\\debug\\appx$/i)) {Object.defineProperty(Debug, "isDebugBuild", {得到:函数(){返回真;}});}}})();
I would like to exclude some code when using release vs debug. Basically I have an internal admin section for testing that I don't to ever make it into the app store by accident :)
Ideally, I would just be able to do something like this:
#IF DEBUG
<div id="appBar" data-win-control="WinJS.UI.AppBar">
<button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'cmdAdmin', label:'Admin', section:'global' }">
</button>
</div>
#ENDIF
解决方案
See here. There is a nuget package here to enable it without adding the code to your project directly. After you have it then you just do:
<script src="/js/debugSymbols.js"></script>
if (Debug.isDebugBuild) {
Here is the full code that you don't need if you use the nuget package:
(function () {
"use strict";
if (Debug.hasOwnProperty("isDebugBuild")) {
return;
}
var thisPackage = Windows.ApplicationModel.Package.current,
installedPath = thisPackage.installedLocation.path;
if (typeof installedPath === "string") {
if (installedPath.match(/\\debug\\appx$/i)) {
Object.defineProperty(Debug, "isDebugBuild", {
get: function () {
return true;
}
});
}
}
})();
这篇关于WinJS 有 #DEBUG 或 #RELEASE 指令吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文