vue全家桶+Koa2开发笔记(8)--开发网页

1.使用 mongoose 动态倒入数据html

 mongoimport -d student -c areas areas.dat vue

-d 后面是数据库名称; -c后面是表名称 最后是数据源ios

 

2.使用vue的watch监听的时候,是能够有参数的:数据库

watch:{
        pvalue:async function(value){
        console.log(value);
        }
}

参数value指的是 pvalue的值。再如,下面的代码参数val表示的是firstName和lastNameaxios

var vm = new Vue({
  el: '#demo',
  data: {
    firstName: 'Foo',
    lastName: 'Bar',
    fullName: 'Foo Bar'
  },
  watch: {
    firstName: function (val) {
      this.fullName = val + ' ' + this.lastName
    },
    lastName: function (val) {
      this.fullName = this.firstName + ' ' + val
    }
  }
})

3. 使用组件的名字,不能和默认的元素名称同样,例以下面的组件占用了html的元素名称:async

<template>
    <div><select/></div>
</template>
<script>
import Select from '@/components/changeCity/isselect.vue'
export default {
    layout:'blank',
    components: {
        Select
    }
}
</script>

这样组件是没法显示。mongoose

4. layout,若是page页面中不定义,则会使用默认的模板。见上图的layout。this

5.将从接口获得的数据复制给state,能够使用下面的方法:spa

getCity:async function(){
            let self = this;
            let {status,data:{city}} = await self.$axios.get(`/geo/getCity`)
            if(status == 200){
                self.city = city.map(item => {
                    return {
                        value:item.id,
                        label:item.name
                    }
                })
            }
}

即便用的map方法复制。code

相关文章
相关标签/搜索