mpvue+vant+flyio+django搭微信小程序(项目)
一、更改vant的样式
<style> .login-btn { background-color: #ee3f4d!important; border: 1PX solid #ee3f4d!important; } </style> <style scoped> 《====注意scoped </style>
重点就是组件上的属性 custom-class
(根节点样式类)和 !important
(优先级,因为根节点样式类是加在 class
开头的),还有就是不要放在 <style scoped>
下,不然会无法修改。
scoped:在vue组件中,在style标签上添加scoped属性,表示样式作用于当下的模块,实现了样式私有化。scoped
设计的初衷就是让样式变得不可修改
二、提交表单
问题:1.form 如何绑定 2.button 如何提交 3.input 如何标记
1.原生
<form bindsubmit="formSubmit"> <button form-type="submit">haha</button>
2.mpvue
<form @submit="formSubmit"> <button form-type="submit">haha</button>
3、mpvue+vant
放弃vant的button了,根本不能和form表单组合
以下是表单提交内容,从回调事件读出
用户信息获取到了,下一步是传给服务器验证
三、使用flyio
post的两种方式
this.$fly.request({ method: 'post', // post/get 请求方式 url: 'http://127.0.0.1:8000/login/', body: {a: "1"} }).then(res => { console.log(res) })
this.$fly.request("http://127.0.0.1:8000/login/",{name: "haha"},{ method:"post", }).then(res => { console.log(res) })
官方文档:https://wendux.github.io/dist/#/doc/flyio/readme
问题:传不过去
解决:
注释掉47行
问题:request.POST为{ }空
在服务器端我用request.POST期望能获取到<QueryDict: {u'key2': [u'value2'], u'key1': [u'value1']}>,但是我发现获取到的是一个空的<QueryDict: {}>,用reqyest.body是能获取到原始的请求内容key2=value2&key1=value1的。
这个时候只能去文档中找答案了,但是貌似Django中的文档也没给出我答案,这时候我就只能通过源码来找答案了,下面是class HttpRequest(object)中获取POST QueryDict的函数部分:
函数看起来有点长,但是我们只要关注后面的if elif else这三个分支即可,从elif self.content_type == 'application/x-www-form-urlencoded':这个分支能看到只有请求header中的'Content-Type':'application/x-www-form-urlencoded'才会填充request.POST,其它情况下只有一个空的<QueryDict: {}>。
从这个问题也看到了Django对'Content-Type':'application/json'没有做任何处理,跟我预想的有一点不一样。
---------------------
作者:NoneSec
来源:****
原文:https://blog.****.net/liuxingen/article/details/54176205
版权声明:本文为博主原创文章,转载请附上博文链接!
四、在服务器上搭环境
1.安装依赖 安装python3 软连接(见https://blog.****.net/six66hao/article/details/80985641
2.安装virtualenv
插曲:使用yum --enablerepo=epel -y install python-virtualenv安装的不太行,卸载:yum erase python-virtualenv
见https://blog.****.net/u012516524/article/details/82154053
3.删除软件
可能会用到
现在采用一键部署的方案
git pull 时每次都要输入用户名和密码的解决办法
git config --global credential.helper store
再操作一次git pull,然后它会提示你输入账号密码,这一次之后就不需要再次输入密码了。