vue init webpack projectname
项目的名称不能大写,不然会报错
npm install -g @vue/cli-init
a)第一项:项目名称,可以直接按enter键
b)第二项:项目描述一个Vue.js,可以直接按enter键
c)第三项:作者名称,输入作者名称:如下图所示
d) 第四项:输入作者名称后按enter键后显示如下图选项,
使用上下箭头选择,通常默认选择第一项,按enter选中
e)第五项:是否安装Vue路由,输入Y/N
f)第六项:使用 ESLint 到你的代码;
ESLint 是在 ECMAScript/JavaScript 代码中识别和报告模式匹配的工具,
它的目标是保证代码的一致性和避免错误。
g)第七项:选择一个预置ESLint,使用上下箭头选择
h)第八项:设置单元测 Y/N
i)第九项:设置端到端测试 Y/N
上述选项设置后选择,选择包管理工具如下所示(npm/yarn)
? Project name godeye
? Project description A Vue.js project
? Author amingMM <1274510382@qq.com>
? Vue build standalone
? Install vue-router? Yes
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Set up unit tests No
? Setup e2e tests with Nightwatch? No
? Should we run `npm install` for you after the project has been created? (recommended) npm
cd godeye
npm run dev
projectName/config/index.js的端口配置
blocked by CORSpolicy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
response =make_response(send_from_directory(path=ss,directory=ss,filename=file_path,as_attachment=True))
response.headers["Content-Disposition"]="attachment; filename={}".format(
file_path.encode().decode('latin-1'))
response.headers["Access-Control-Allow-Origin"]="*"
docx-preview.js
https://zhuanlan.zhihu.com/p/437059185https://github.com/vuejs/devtools
Cannot use import statement outside a module
用了es6的语法, 浏览器默认将它作为js解析会出现问题,需要将它作为模块导入,script标签默认type="text/javascript",需要改为type="module",更改后的index.html:<script type="module"/**
* 第一个参数: data为文件流,Blob | ArrayBuffer | Uint8Array 格式
* 第二个参数: 渲染到页面的dom元素
* 第三个参数: 渲染word文档的样式的元素,如果为null,则设置到第二个参数的DOM上
* 第四个参数: 配置对象
*/
docx.renderAsync(data,this.$refs.file,null,{
className:'text-docx',//class name/prefix for default and document style classesinWrapper:true,//enables rendering of wrapper around document contentignoreWidth:false,//disables rendering width of pageignoreHeight:false,//disables rendering height of pageignoreFonts:false,//disables fonts renderingbreakPages:true,//enables page breaking on page breaksignoreLastRenderedPageBreak:true,//disables page breaking on lastRenderedPageBreak elementsexperimental:true,//enables experimental features (tab stops calculation)trimXmlDeclaration:true,//if true, xml declaration will be removed from xml documents before parsinguseBase64URL:false,//if true, images, fonts, etc. will be converted to base 64 URL, otherwise URL.createObjectURL is useduseMathMLPolyfill:true,//includes MathML polyfills for chrome, edge, etc.debug:false//enables additional logging})// 渲染到页面
this.$refs.ref_name.功能
ref有在mounted中才能使用
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>测试vue</title><script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script></head><body><div id="vueController">{
{
msg}}<br><!--这个输入框绑定msg的值--><input type="text" v-model="msg"><br><!--绑定changeMsg方法到按钮上--><input type="button" value="点我" @click="changeMsg"></div><script>var test =newVue({
el:"#vueController",data:{
msg:""},methods:{
changeMsg:function(){
var that =this;
that.msg ="因崔斯听";}},mounted:function(){
var that =this;
that.msg ="hello vue";}})</script></body></html>