RE:Newal!
- changed project style more silimar to vuejs 2.x template
- use vue file by vbuild
Install
using pip
pip install pyvuejs
Usage
start server by main.py file in project directory
python ./main.py
serve configurations
config update by Vue.use in main.py
- parameters
- host[str]: host url of server(default: "0.0.0.0")
- port[int]: port number of server(default: 47372)
- debug[bool]: flag of show bottle log(default: True)
- open_webbrowser[bool]: flag of open browser when start(default: True)
Vue.use(
VueConfig(
host = "0.0.0.0",
port = 47372,
debug = True,
open_webbrowser = True
)
)
view/component editing guide
same as vue.js, can support by linting
- for now, template, style, script blocks are supported
- more information on vbuild and vbuild python document
<!-- template block -->
<template>
<div>
<label>{{ count }}</label>
<div>
<button style="margin-right:10px;" v-on:click="up_count">up</button>
<button v-on:click="down_count">down</button>
</div>
</div>
</template>
<!-- style block -->
<style scoped>
button {
width: 80px;
}
</style>
<!-- script block -->
<script lang="python">
class Component:
def __init__(self):
self.count = 0
def up_count(self):
self.count += 1
def down_count(self):
if self.count > 0:
self.count -= 1
</script>
use view/component
just call name in other view
<template>
<div id="app">
<div id="nav">
<router-link to="/Home">Home</router-link> |
<router-link to="/About">About</router-link> |
<router-link to="/Counter">Counter</router-link>
</div>
<router-view/>
</div>
</template>
events mapping
define map class and map functions in each file of maps
- if debug option in config, functions can be reached by "GET" and "POST". else, "POST" only
from pyvuejs import VueMap
class Counter(VueMap):
count = 0
@VueMap.map
def get_count(self):
return self.count
@VueMap.map
def up_count(self):
self.count += 1
@VueMap.map
def down_count(self):
if self.count > 0:
self.count -= 1
routes
define route path and component in router.py
from pyvuejs import Vue, VueRouter
Vue.use(VueRouter([
{
"path": "/About",
"component": "About"
},
{
"path": "/Home",
"component": "Home"
},
{
"path": "/Counter",
"component": "Counter"
}
]))
Todo
- routes
License
pyvuejs is MIT license
Metadata
Release files for pyvuejs 2.0.5.post3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyvuejs-2.0.5.post3.tar.gz | 77.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyvuejs-2.0.5.post3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 156.9 kB
Release files / pyvuejs-2.0.5.post3.tar.gz
| Download URL | pyvuejs-2.0.5.post3.tar.gz |
|---|---|
| Size | 77.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70b325f145addd5e3fb9bcaae6dd1e5718ea14112e5b364b5e8aab4d8cef1806
|
|
BLAKE2b-256 checksum How to use checksums |
014fe83b11933c70f011ae733e9ceb0493ee2702601b3100ed361cafdbb26ab8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9
|
Release files / pyvuejs-2.0.5.post3-py3-none-any.whl
| Download URL | pyvuejs-2.0.5.post3-py3-none-any.whl |
|---|---|
| Size | 79.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d60cfd59c5cead696a4eb741253cf263607cf6c6d5c5edbd09533741832b37d
|
|
BLAKE2b-256 checksum How to use checksums |
25f0aaea0a61c236f6c5b9072be0c2522663031a7801e84e43d936ab0add84be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9
|