随笔分类 - vue
摘要:当vue的data里边声明或者已经赋值过的对象或者数组(数组里边的值是对象)时,向对象中添加新的属性,如果更新此属性的值,是不会更新视图的。
阅读全文
摘要:在vue的组件通信props中,一般情况下,数据都是单向的,子组件不会更改父组件的值,那么vue提供.sync作为双向传递的关键字,实现了父组件的变动会传递给子组件,而子组件的carts改变时,通过事件机制,修改父组件的cart。完成了子组件carts和父组件cart的双向映射。
阅读全文
摘要:let routeData = this.$router.resolve({ name: 'commercialPreview', query: {cylType: this.$route.query.cylType}, params: { id: this.id } }) window.open(routeData.href, '_blank')
阅读全文
摘要:在vue中computed是计算属性,主要作用是把数据存储到内存中,减少不必要的请求,还可以利用computed给子组件的data赋值。 参考地址:https://www.jianshu.com/p/ff708a773dc0
阅读全文
摘要:使用import需要babel编译写法如下 项目中使用sass 辅助工具安装 MongoDB(http://www.runoob.com/mongodb/mongodb-window-install.html) redis(http://www.runoob.com/redis/redis-inst
阅读全文
摘要:使用asyncData就是服务端渲染,computed只是浏览器的渲染刷新会有闪烁
阅读全文
摘要://在server/interface/city.js import Router from 'koa-router'; const router = new Router({ prefix:'/city' //给路由添加前缀 }) router.get('/list', async (ctx) => { ctx.body=['北京','天津'] }) export def...
阅读全文
摘要:layout是页面模板,主要是为了做到无论在任何页面都会显示的内容,例如头部header,或者nav导航,页脚等固定页面。nuxt配置以及layout具体参考(https://cloud.tencent.com/developer/article/1330974) 1.如果项目中存在 layouts
阅读全文
摘要:1.使用 npm 安装 npm install -g vue-cli 2.安装nuxt项目 vue init nuxt-community/koa-template 项目名称 3.如果 vue-cli 没有安装, 需先通过 npm install -g vue-cli 来安装。 4.进入项目npm
阅读全文
摘要:const router = require('koa-router')() //返回一个页面 router.get('/', async (ctx, next) => { global.console.log('index11111'); await ctx.render('index', { //render返回一个页面 title: 'Hello Koa 2!' ...
阅读全文
摘要:function pv(ctx){ global.console.log(ctx.path); } module.exports=function(){ return async function(ctx,next){ pv(ctx); await next(); //next是继续执行下面的中间件,如果不写会直接跳出,不会继续执行 } ...
阅读全文
摘要:1.npm install -g koa-generator 2.koa2 项目名称,如果需要ejs引擎koa2 -e 项目名称 3.cd 项目名称 4.npm install 5.npm install --update-binary 6.npm run dev 小知识点:对于start和test
阅读全文
摘要://v-bind:id="变量" or :id="变量"
阅读全文
摘要:如果返回的数据是html标签字符串的话,在vue里要通过v-html来渲染
阅读全文