python module
1.0.0
在Python中寫NUXT.JS應用程序
發行說明
npm install # or use yarn
pip install -r requirements.txt
npm run dev @nuxtjs/python依賴性@nuxtjs/python添加到nuxt.config.js的modules部分 {
modules : [
'@nuxtjs/python'
] ,
python : {
compiler : 'pj' // default
}
}<script lang="py"> 。compiler參數) 編譯器默認值和建議的是Javascripthon ,但可以使用其他編譯器(見下文)。
安裝Javascripthon Python Transpiler。目前,您需要主分支機構:
pip install -e git+https://gitlab.com/metapensiero/metapensiero.pj#egg=javascripthon
請注意,Javascripthon要求您擁有Python 3.5 (或更好)。
JavasCripthon支持將Python導入語句轉換為NUXT中使用的ES6導入。請注意語法轉換。
您可以通過使用模塊選項或在nuxt.config.js文件中的python部分中將compiler選項傳遞給PY-LOADER。
Transcrypt具有自己的模塊系統,因此為了使用它,您可以使用COMPORJS模塊標準( require導入和module.exports 。請參閱py-loader vuejs示例。
.vue文件提示,如果使用VIM,則可以通過安裝VIM-VUE插件並應用此補丁來獲得HTML,CSS和Python的語法突出顯示。
hello.vue :
< template >
< div >
Nuxt {{ best_lang }}
</ div >
</ template >
< script lang =" py " >
class Component :
def __init__ ( self ) :
self [ ' data '] = lambda: { ' best_lang ': ' Python ' }
__default__ = Component ( )
</ script >.py文件用於其他NUXT文件store/index.py
from vuex import Store
def increment ( state ):
state . counter = state . counter + 1
def createStore ():
return Store (
state = { 'counter' : 0 },
mutations = { 'increment' : increment }
)
__default__ = createStore pages/counter.vue
< template >
< h2 > {{ $store.state.counter }} </ h2 >
< button @click =" $store.commit('increment') " > +1 </ button >
</ template >有關工作示例,請參見此處。
yarn install或npm install安裝依賴項npm run dev啟動開發服務器麻省理工學院許可證
版權(C)Sebastian Silva [email protected]
該模塊是由Pooya Parsa的模塊模塊開始的,並嚴重依賴Martim Nascimento和Alberto Berti的Javascripthon的Python-Webpack-loader。