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。