javascript alert()函数在UWP应用程序中不起作用(javascript alert() function not working in UWP app)
我使用了一些基本的javascript代码并用它来制作一个简单的UWP应用程序,当我在浏览器中运行文件时代码中的警报功能正常工作,但是当我在UWP应用程序中尝试它时它不起作用。 下面是代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>App6</title> <!-- WinJS references --> <link href="WinJS/css/ui-dark.css" rel="stylesheet" /> <script src="WinJS/js/base.js"></script> <script src="WinJS/js/ui.js"></script> <!-- App6 references --> <link href="/css/default.css" rel="stylesheet" /> <script src="/js/default.js"></script> </head> <body class="win-type-body" onload="alert('oh yeah');"> </body> </html>
I used some little basic javascript code and used it to make a simple UWP app, the alert function in the code works when i run the file in the browser, but it doesnt work when i try it in UWP app. below is the code
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>App6</title> <!-- WinJS references --> <link href="WinJS/css/ui-dark.css" rel="stylesheet" /> <script src="WinJS/js/base.js"></script> <script src="WinJS/js/ui.js"></script> <!-- App6 references --> <link href="/css/default.css" rel="stylesheet" /> <script src="/js/default.js"></script> </head> <body class="win-type-body" onload="alert('oh yeah');"> </body> </html>
原文:https://stackoverflow.com/questions/33439818
最满意答案
那些是不同的Ts。
scala> type T[T] = { def f: T } defined type alias T scala> var x: T[Int] = null x: T[Int] = null scala> x = new AnyRef { def f = 5 } x: T[Int] = $anon$1@44daa9f1
当你写:
type Addable[Addable] = { def +(a : Addable) : Addable }
你有一个Addable类型的参数,也叫做Addable。 这是人们经常混淆的类似变化。
scala> def f[Int](x: Int) = x * x <console>:7: error: value * is not a member of type parameter Int def f[Int](x: Int) = x * x ^
你的问题的实际答案是“你不能”,但我不愿意粉碎你的宗教信仰,所以我会说“结构类型以神秘的方式工作”。 如果你想参加一个宗教使命,你可能会在这里访问,这就解释了为什么你不能。
Those are different Ts.
scala> type T[T] = { def f: T } defined type alias T scala> var x: T[Int] = null x: T[Int] = null scala> x = new AnyRef { def f = 5 } x: T[Int] = $anon$1@44daa9f1
When you write:
type Addable[Addable] = { def +(a : Addable) : Addable }
You have a type Addable which takes a single type parameter, also called Addable. Here's a similar variation people often confuse themselves with.
scala> def f[Int](x: Int) = x * x <console>:7: error: value * is not a member of type parameter Int def f[Int](x: Int) = x * x ^
The actual answer to your question is "you can't" but I would hate to shatter your religious-like faith so instead I'll say "structural types work in mysterious ways." If you want to go on a religious mission you might visit here, which explains why you can't.
相关问答
更多-
自引用鸭子打字(Self-referential duck-typing)[2022-12-14]
那些是不同的Ts。 scala> type T[T] = { def f: T } defined type alias T scala> var x: T[Int] = null x: T[Int] = null scala> x = new AnyRef { def f = 5 } x: T[Int] = $anon$1@44daa9f1 当你写: type Addable[Addable] = { def +(a : Addable) : Addable } 你有一个Addable类型的参 ... -
鸭子打字在Javascript(Duck Typing in Javascript)[2021-07-16]
第二个链接给出了一个在js中类似鸭子的模式的例子。 不是说我建议这样做,但是好的,你问了这个。 ;) 在面向对象编程语言的计算机编程中,鸭型打字是一种动态打字的风格,其中对象的当前方法和属性集确定有效语义,而不是从特定类或特定接口的实现继承。 维基百科 - 鸭打字 最简单的方法是非正式地定义合同,并且只需依靠接口每一侧的开发人员知道他们在做什么。 戴维·托马斯(Dave Thomas)把这种方式称之为“鸭子打字” - 如果它像鸭子一样走,像鸭子一样,那么它就是一只鸭子。 类似于我们的Shape界面,如果它可 ... -
什么是鸭子打字?(What is duck typing?)[2023-02-22]
这是一种用于动态语言的术语,没有强力打字 。 这个想法是,您不需要一种类型来调用对象上的现有方法 - 如果在其上定义了一种方法,则可以调用它。 这个名字来自“如果看起来像鸭子,像鸭子一样,这是一只鸭子”。 维基百科有更多的信息。 It is a term used in dynamic languages that do not have strong typing. The idea is that you don't need a type in order to invoke an existing ... -
Common Lisp对象系统(CLOS)是否支持鸭子打字?(Does the Common Lisp Object System (CLOS) support duck-typing?)[2024-01-12]
也许不需要输入鸭子,因为CLOS并不遵循消息传递原则,而且方法也不会被绑定到类上。 情况正是如此。 每个泛型函数都可以动态地专门针对某个类。 也可以有一个默认的实现。 而且由于Lisp使用动态类型,每个函数都可以用任何类型的参数调用,而对于泛型函数,基于参数类型的调度决策在运行时会被采用。 Perhaps duck-typing is not needed because CLOS doesn't follow a message passing philosophy and methods are not ... -
通用鸭子在F#打字?(generic duck typing in F#?)[2022-08-25]
您可以使用F#PowerPack中的组件编译F#引用。 所以我认为你可以使用引号在运行时生成和执行代码。 如果你编写一个代表函数的引用并编译它,你将获得一个可用于实现接口的函数值。 这是一个简单的例子: #r "FSharp.PowerPack.Linq.dll" open Microsoft.FSharp.Quotations open Microsoft.FSharp.Linq.QuotationEvaluation // Create a part using "Expr." calls expli ... -
任何动态类型的oop语言都支持duck-typing,包括php。 它不是一个功能,而是编程风格。 Any dynamically-typed oop language supports duck-typing, including php. It's not a feature, it's rather programming style.
-
逼真的为什么我会使用鸭子打字或控制反转?(Realisticly why would I use duck-typing or inversion of control? [closed])[2022-11-29]
即使您没有像评论中暗示的那样“为其他开发人员开发代码”,编码到接口也有很多好处。 讨论这些好处是值得的,但由于问题要求现实世界的例子/用例,这里有: 供测试用。 IoC可以很容易地引入模拟和其他简化/测试类,这些类允许测试特定单元,而无需将项目的所有依赖项纳入其中。 用于在某些依赖项可用之前实现应用程序的特定部分。 (类似于测试用例) 为不同用户提供不同的功能集。 您可以拥有给定模块的多个“版本”,并将适当的模块提供给不同类型的客户:评估版,标准版,高级版甚至Beta测试版。 只要模块的API得到尊重,应用 ... -
这很俗气: scala> def test(x: { def x(a:Int, b:Int):Int ; def x$default$2: Int } ) = x.x(1, x.x$default$2) warning: there were 2 feature warning(s); re-run with -feature for details test: (x: AnyRef{def x(a: Int,b: Int): Int; def x$default$2: Int})Int scala> v ...
-
没有明确的答案; 这取决于你的课程做什么。 检查你的Hero.equip isinstance(weapon, Weapon)以检查该物品是否是武器并不是那么可怕。 此外,如果您要像第二个示例中那样涉及两个对象,则可以将更多处理移动到Hero中: class Hero: def __init__(self): self.weapon = None self.inTummy = None def equip(self, weapon): pri ...
-
这是一个圆椭圆问题 。 我不会覆盖这个功能; 相反,我会将函数重命名为更具体。 所以在AppleBasket中将它重命名为getRandomApple()。 你的语义变得有些混乱,所以我会把事情分开并且更加清晰。 你不能在FruitBasket中更改函数名称太糟糕了,因为我会将其更改为getRandomFruit()以使语义更清晰。 This is a circle-ellipse problem. I would simply not override the function; rather I wou ...