我正在关注angular.io的Angular2快速入门指南 他们利用systemJs进行app加载。
angular2,rx.js和angular2.dev.js通过脚本引用加载而不是导入..
无论如何都要导入这些脚本吗?
class PurchaseEntry(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
PurchaseEntry.configure(self, bg='white')
label = ttk.Label(self, text='Purchase Entry', font=LARGE_FONT2)
label.grid(row=0, columnspan=3, sticky='w')
purchase_entry = ttk.Label(self, text='Purchase Entry:')
purchase_entry.grid(row=1, column=0)
self.entry_val = tk.StringVar()
self.entry_1 = ttk.Entry(self, width=100, textvariable=self.entry_val)
self.entry_1.grid(row=1, column=2, columnspan=2, sticky='w')
self.entry_1.focus()
self.entry_btn = ttk.Button(self,text='Enter', command=self.insert_value)
self.entry_btn.grid(row=1, column=4, columnspan=2, sticky='w')
self.chat1 = ttk.Treeview(self)
chat1 = ttk.Treeview( self, height=28, columns=('dose', 'date modified'), selectmode="extended")
chat1.heading('#0', text='item', anchor=tk.CENTER)
chat1.heading('#1', text='dose', anchor=tk.CENTER)
chat1.heading('#2', text='date modified', anchor=tk.CENTER)
chat1.column('#1', stretch=tk.YES, minwidth=50, width=100)
chat1.column('#2', stretch=tk.YES, minwidth=50, width=120)
chat1.column('#0', stretch=tk.YES, minwidth=50, width=400)
chat1.grid(row=2, column=2, columnspan=4, sticky='nsew')
def insert_value(self):
value = self.entry_val.get()
# Inserts data written in the entry box to the treeview widget when Enter button is pressed.
# Clears the Entry box, ready for another data entry.
self.entry_1.delete(0, 'end')
self.chat1.insert('WHAT SHOULD I GIVE AS AN ARGUMENT?')
答案 0 :(得分:1)
包含Angular2包使用System.register
方法直接注册其包。
那就是说你也可以使用以下配置配置SystemJS来为每个模块的文件加载Angular2文件,但效率较低:
<script src="node_modules/es6-promise/dist/es6-promise.js"></script>
<script src="node_modules/es6-shim/es6-shim.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.min.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script>
System.config({
defaultJSExtensions: true,
map: {
angular2: 'node_modules/angular2/src',
rxjs: 'node_modules/rxjs'
},
packages: {
app: {
defaultExtension: 'js',
format: 'register'
},
angular2: {
defaultExtension: 'js',
}
}
});
(...)
</script>
在这两种情况下,都可以在应用程序中导入相应的模块(angular2/*
,rxjs/*
)。