测试render
print(‘hello‘ .. ‘ ‘ .. ‘world!‘) -- This is Lua!
print(js.global:eval(‘[0,1,2,3,4,5][3]‘)) -- Run JS from Lua
-- Interact with the page using Lua
local screen = js.global.screen
print("you haz " .. (screen.width*screen.height) .. " pixels")
local window = js.global -- global object in JS is the window
window:alert("hello from lua!")
window:setTimeout(function() print(‘hello from lua callback‘) end, 2500)
local document = js.global.document
print("this window has title ‘" .. document.title .. "‘")
-- call constructors (global, or as properties of other objects)
print("i made an ArrayBuffer of size " .. js.new(js.global.ArrayBuffer, 20).byteLength)
-- print("i made an ArrayBuffer of size " .. js.global.ArrayBuffer:new(20).byteLength)
print("time iz " .. js.global.Date.now()) -- call with no arguments
print(‘done!‘)
output
Execute »