我想创建带有HTML页面的输出界面,帮助定义属性,但是我找不到如何通过名称为属性设置变量。
var _root = {};
var value = 2;
Object.defineProperty(_root, "MyProperty", {
get: function(){
return value;
}
,
set: function(val){
value = val;
},
enumerable: true,
configurable: true
});
function SetValue( nameProperty , value ){
nameProperty = value;
}
function GetValue( nameProperty){
return eval(nameProperty);
}
SetValue("_root.MyProperty","35"); // This function is called from C# webBrowser.Document.InvokeScript("SetValue" , new Object[]{"_root.MyProperty","35" });
console.log( GetValue( "_root.MyProperty"));
修改 我尝试用eval设置值,但它不起作用。
function SetValue( nameProperty , value ){
var ob = eval(nameProperty);
ob =value;
}
答案 0 :(得分:0)
答案 1 :(得分:0)
我找到了解决问题的方法。
NSString *url = @"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
AVPlayer *player = [AVPlayer playerWithURL:[NSURL URLWithString:url]];
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
playerViewController.player = player;
[self.view addSubview:playerViewController.view];
[self presentViewController:playerViewController animated:YES completion:nil];