GithubHelp home page GithubHelp logo

lzxb / vuet Goto Github PK

View Code? Open in Web Editor NEW
423.0 27.0 74.0 1.15 MB

允许你定义飙车过程的集中式状态管理模式

License: MIT License

JavaScript 100.00%
vue vuejs2 vue-router vuex vuet vuejs vue-plugin

vuet's Introduction

vuet's People

Contributors

leask avatar lzxb avatar pixcai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vuet's Issues

polyfill 支持不太好

你好,我在项目中使用发现 Object.assign 方法报错,此方法的 polyfill 没包含在包中。
测试机:

  1. iPhone 5 ,ios 8。
  2. 魅族自带手机浏览器。
    希望能解决,谢谢。

在fetch中不能写异步请求?

import {addressList} from '@/api'
import { mapModules, mapRules } from 'vuet'

const mixins = [
  mapModules({
    $address: 'address'
  }),
  mapRules({
    once: [{ path: 'address' }]
  })
]

export default {
  mixins,
  module: {
    data () {
      return {
        data: ''
      }
    },
    fetch (uid) {
      setTimeout(() => {
         this.data = 'fetch'
      }, 1000)
      

    },
    async getData(uid = 1) {
      setTimeout(() => {
        this.data = 111
      }, 1000)

      return
      let res = await addressList({uid})
      this.data = res.data
    }
  }
}

这么写 data 返回的 居然是 function proxy() { return native.apply(vuet.modules[path], arguments); }

规则reset后,不再触发once

在字典画面设置reset:['dict'],
然后返回业务画面时,once:['dict']没有重新触发。

按照常理,rest后,不应该把'dict'重置为最初状态嘛?

有没有严格模式的设置?

有没有严格模式的设置,不知道vuet在设计时是不是遵循了单向数据流的概念。如果遵循了单向数据流,那么怎么设置才能不直接修改变量造成了ui改变?
比如我的vuet代码

//vuet 代码
export default new Vuet({
    pathJoin: '-',
    modules: {
        topic: {
            data () {
                return {
                    count: 0
                }
            }
            ,addCount:function(){
                this.count ++;
            }
            ,modules:{
                list:{
                    data(){
                        return {
                            name:"list"
                        }
                    }
                }
            }
        }
    }
});
//vue页面代码
<template>
<div>
    {{topic.count}}
    <button @click="addEvent">++</button>
</div>
</template> 

<script>
export default{
    mixins: [
        mapModules({
            topic: 'topic' // { 别名: '模块路径' }
            ,list:'topic-list'
        })
    ]
    ,methods:{
        addEvent:function(){
            (this.topicModel.count)++
        }
    }
}
</script>

上述的代码中通过addEvent直接就操作了store中的属性,这是案例说违反了单向数据流的严格模式。在严格模式中属性的改变应该通过action来驱动。

出了vuex还有mobx类库,这个类库默认情况也是可以直接修改属性,但是可以配置一下变成严格模式,严格模式下就只能通过action来改变属性。

在mouted事件里获取vuet里面的data字段值为空

import { mapModules, mapRules } from 'vuet'

export default {
mixins: [
mapModules({ data2: 'topic-detail'}),
mapRules({ route: 'topic-detail' })
],
computed:{
topic(){
return this.data2.topic
}
},
mounted(){
console.log(JSON.stringify(this.data2)) //这里打印出来都是空值,为什么呢
var imgs=this.topic;
console.log(JSON.stringify(imgs)) //这里打印出来都是空值,为什么呢
}
}

请教个vuet问题,应该在哪里只调用一次方法,返回回来后不会再次触发

我在vuet中定义了一个模块,用来显示“图片幻灯片”,
运行起来后,第一次是正常的,但是点击其中一张图片进去查看之后,再点击返回,图片幻灯片成倍显示了,代码如下
vuet模块代码如下
modules: {
topic: {
modules: {
slider:{
data () {
return {
list: []
}
},
route: {
once: true // 当前页面,只加载一次,这样我们就可以做上拉加载了
},
async fetch () {
const res = await http.get('News/slides?time='+Math.random())
//alert(res.data);
this.list = [...this.list, ...res.data]
}
}
}
}
}

调用页面代码如下

export default {
mixins: [
mapModules({ data: 'topic-newslist',pic:'topic-slider' }),
mapRules({ route: 'topic-newslist' })
],
mounted(){
this.pic.fetch();
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.