为vuejs前端提供静态页面
django-sfp的Python项目详细描述
django sfp
==br/>
为vuejs前端提供平面页面
**fast**:无数据库访问
**safe**:将页面保存在版本控制系统中
**friendly**:在IDE中编辑页面
**cache**:感谢[Apollo客户端](https://www.apollographql.com/)
将“sfp”添加到“已安装的应用程序”中。在设置中声明graphql模式:
```python
graphene={
`schema':'sfp.schema.schema',
}
````
>3。添加graphql终结点url:
`` python
来自django.views.decorators.csrf导入csrf免除
来自graphene django.views导入graphql view
urlpatterns=[
…
url(r'^graphql',csrf免除(graphqlview.as_view()),
]
````
4。安装前端:
获取“page.vue”组件:
``bash
wget https://raw.githubusercontent.com/synw/django sfp/master/frontend/src/components/page.vue
````
安装依赖项:
````````
npm install--save vue apollo//或vue add apollo如果使用vue cli
npm install--save@fortawesome/font awesome svg core
npm install--save@fortawesome/free solid svg icons
npm install--save@fortawesome/vue fontawesome
````
fontawesome用于微调器加载图标(仅此图标将包含在生成中,
不包括整个库)。必须安装Vue路由器
5。添加前端通用路由:
``javascript
import page from'./path/to/my/components/page.vue'
routes:[
/…
{
{path:'*',
name:'page',
component:page
},
,
`````
以生成链接:``<;路由器链接:to={name:'page',参数:{0:'/myurl'}“>;<;/router link>;``
用法
----
在django项目静态目录中创建一个``pages`'。任何包含在其中的html文件都将被用作静态页。
例如::
*url```/about/``将呈现``static/pages/about.html``
*url``/about/team/``将呈现``static/pages/about/team.html``
注意:每个文件的第一行是页面的标题:例如:
``html
`my pagetitle
<;div>;我的页面内容<;div>;
````
==br/>
为vuejs前端提供平面页面
**fast**:无数据库访问
**safe**:将页面保存在版本控制系统中
**friendly**:在IDE中编辑页面
**cache**:感谢[Apollo客户端](https://www.apollographql.com/)
将“sfp”添加到“已安装的应用程序”中。在设置中声明graphql模式:
```python
graphene={
`schema':'sfp.schema.schema',
}
````
>3。添加graphql终结点url:
`` python
来自django.views.decorators.csrf导入csrf免除
来自graphene django.views导入graphql view
urlpatterns=[
…
url(r'^graphql',csrf免除(graphqlview.as_view()),
]
````
4。安装前端:
获取“page.vue”组件:
``bash
wget https://raw.githubusercontent.com/synw/django sfp/master/frontend/src/components/page.vue
````
安装依赖项:
````````
npm install--save vue apollo//或vue add apollo如果使用vue cli
npm install--save@fortawesome/font awesome svg core
npm install--save@fortawesome/free solid svg icons
npm install--save@fortawesome/vue fontawesome
````
fontawesome用于微调器加载图标(仅此图标将包含在生成中,
不包括整个库)。必须安装Vue路由器
5。添加前端通用路由:
``javascript
import page from'./path/to/my/components/page.vue'
routes:[
/…
{
{path:'*',
name:'page',
component:page
},
,
`````
以生成链接:``<;路由器链接:to={name:'page',参数:{0:'/myurl'}“>;<;/router link>;``
用法
----
在django项目静态目录中创建一个``pages`'。任何包含在其中的html文件都将被用作静态页。
例如::
*url```/about/``将呈现``static/pages/about.html``
*url``/about/team/``将呈现``static/pages/about/team.html``
注意:每个文件的第一行是页面的标题:例如:
``html
`my pagetitle
<;div>;我的页面内容<;div>;
````