下午好,
我這里有一段代碼,您可以在 SketchUp 的 Ruby 控制臺中運行它。當你這樣做時,你會得到一個列印字母'a'的彈出視窗。但是在我的代碼中,您可以看到我已將“a”標識為字串“50.12”。
dialog = UI::HtmlDialog.new(
{
:dialog_title => "Observation Information Plugin",
:scrollable => true,
:resizable => true,
:width => 500,
:height => 200,
:left => 200,
:top => 200,
:min_width => 50,
:min_height => 50,
:max_width =>1000,
:max_height => 500,
:style => UI::HtmlDialog::STYLE_DIALOG
})
a = 50.12
a = a.to_s
html = "
<!DOCTYPE html>
<html>
<body>
<script type = 'text/javascript'>
document.write('<p>a</p>');
</script>
</body>
</html>
"
dialog.set_html(html)
dialog.show
我可以做些什么來修改我的代碼的 HTML 部分以使腳本在螢屏上列印 50.12 而不是字母“a”?
謝謝你的幫助!
uj5u.com熱心網友回復:
您需要使用字串插值。替換document.write('<p>a</p>');為document.write('<p>#{a}</p>');
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/431896.html
