跳到主要内容

数据上下文(DataContext)

提供层级数据(hierarchical data)及其关联视图模型(ViewModel)的访问能力。

方法(Methods)

parent

返回父数据上下文(若存在)。

function init(self: MyNode, context: Context): boolean
local dc = context:dataContext()
if dc then
local parentDC = dc:parent()
local vm = dc:viewModel()
end

return true
end

viewModel

返回当前上下文关联的视图模型。

function init(self: MyNode, context: Context): boolean
local dc = context:dataContext()
if dc then
local parentDC = dc:parent()
local vm = dc:viewModel()
end

return true
end