在下面的代码中,我可以像这样访问<!DOCTYPE html>
<html>
<head>
<title>evaluasiModel</title>
</head>
<body>
<div id="container">
<div id="result">
hasilSkoring: {{ hasilSkoring }}
</div>
</div>
</body>
</html>
:wrapper
tutorial.screen1.wrapper
由于无法访问var tutorial = {
screen1: {
text: '<div class="text">Click this to continue</div>',
wrapper: '<div class="tutorial tutorial-screen-1">' + this.text + '</div>'
}
,this.text
会引发错误。
如何使tutorial.screen1.wrapper
在对象中工作?
答案 0 :(得分:1)
您可以通过创建wrapper
作为功能
var tutorial = {
screen1: {
text: '<div class="text">Click this to continue</div>',
wrapper: function() {
return '<div class="tutorial tutorial-screen-1">' + this.text + '</div>'
}
}
}
console.log(tutorial.screen1.wrapper())