{"id":13508965,"url":"https://github.com/xiaofuzi/re-vue","last_synced_at":"2025-04-13T02:32:42.072Z","repository":{"id":65516639,"uuid":"73285249","full_name":"xiaofuzi/re-vue","owner":"xiaofuzi","description":"rewrite vue.js","archived":false,"fork":false,"pushed_at":"2017-09-29T02:36:09.000Z","size":169,"stargazers_count":39,"open_issues_count":3,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T09:20:22.374Z","etag":null,"topics":["framework","learning-by-doing","vuejs"],"latest_commit_sha":null,"homepage":"https://github.com/xiaofuzi/deep-in-vue","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xiaofuzi.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-09T13:11:29.000Z","updated_at":"2025-01-01T05:27:42.000Z","dependencies_parsed_at":"2023-01-26T22:25:11.715Z","dependency_job_id":null,"html_url":"https://github.com/xiaofuzi/re-vue","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaofuzi%2Fre-vue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaofuzi%2Fre-vue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaofuzi%2Fre-vue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaofuzi%2Fre-vue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiaofuzi","download_url":"https://codeload.github.com/xiaofuzi/re-vue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657825,"owners_count":21140842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework","learning-by-doing","vuejs"],"created_at":"2024-08-01T02:01:01.100Z","updated_at":"2025-04-13T02:32:41.831Z","avatar_url":"https://github.com/xiaofuzi.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"## tiny-vue\n\nrewrite vue.js.\n\n包含一个比较完整的基本项目，webpack打包、mocha测试、eslint代码校验.\n\n[online demo](http://yangxiaofu.com/re-vue/examples/tiny-vue.html)\n\n[实现原理分析:https://github.com/xiaofuzi/deep-in-vue](https://github.com/xiaofuzi/deep-in-vue)\n\n### 特性\n\n* 双向绑定\n* 计算属性\n* 事件支持\n* watch监测\n* 生命周期函数\n* 预定义指令\n* 自定义指令\n* 组件系统\n\n### Usage\n\nexample:\n\n```html\n\u003cdiv id=\"app\"\u003e\n    \u003ch2 v-text='hello' v-visible='isShow'\u003e\u003c/h2\u003e\n    \u003cinput type=\"text\" v-model='counter'\u003e\n    \u003cbutton v-on:click='add' type=\"button\"\u003eadd\u003c/button\u003e        \n    \u003cbutton v-on:click='toggle' type=\"button\"\u003etoggle\u003c/button\u003e\n    \u003cp v-text='counter'\u003e\u003c/p\u003e\n    \u003cp v-text='info.age'\u003e\u003c/p\u003e\n    \u003cp v-text='wellcome.text'\u003e\u003c/p\u003e\n\u003c/div\u003e\n```\n\n```js\nvar mvvm;\nvar opts = {\n    el: '#app',\n    data: {\n        isShow: false,\n        counter: 1,\n        hello: 'ahahah!',\n        info: {\n            age: 18\n        },\n        person: {\n            weight: 20,\n            height: 170\n        }\n    },\n    computed: {\n        wellcome () {\n            return {text: this.hello + '---' + this.info.age};\n        }\n    },\n    methods: {\n        add: function () {\n            this.counter += 1;\n            this.info.age += 1;\n        },\n        toggle: function () {\n            this.isShow = !this.isShow;                    \n        }\n    },\n    watch: {\n        counter (val) {\n            console.log('counter: ', val);\n        },\n        info (info) {\n            console.log('info: ', info);\n        },\n        'info.age' () {\n\n        },\n        wellcome () {\n            console.log('wellcome: ', this.wellcome);\n        }\n    },\n    ready () {\n        let self = this;\n        self.hello = 'Ready, go!';\n        \n        setTimeout(function () {\n            self.hello = 'Done!';\n        }, 1000)\n    }\n}\n\nTinyVue.$directive('visible', function (value) {\n    this.el.style.visibility = value ? 'visible' : 'hidden';\n})\nmvvm = new TinyVue(opts);\n```\n### 组件系统示例\n\n```html\n\u003cdiv id=\"app\"\u003e        \n    \u003ch2\u003e组件系统示例\u003c/h2\u003e\n    \u003csub-component\u003e\u003c/sub-component\u003e\n    \u003chello-world hello='hello world!' :msg='message'\u003e\u003c/hello-world\u003e  \n\u003c/div\u003e\n```\n\n```js\nvar mvvm;\nvar subComponent = {\n    template: '\u003cdiv\u003e\u003ch2 v-text=\"name\"\u003e\u003c/h2\u003e\u003c/div\u003e',\n    data: function (){\n        return {\n            name: 'an new component!'\n        }\n    },\n    props: ['info']\n}\n\nTinyVue.component('hello-world', {\n    template: '\u003cdiv\u003e\u003ch2 v-text=\"hello\"\u003e\u003c/h2\u003e\u003ch3 v-text=\"msg\"\u003e\u003c/h3\u003e\u003c/div\u003e',\n    data: function (){\n        return {\n            name: 'hello world component!'\n        }\n    },\n    props: ['hello', 'msg']\n});\nvar opts = {\n    el: '#app',\n    data: {\n        message: 'the fast mvvm framework.'\n    },\n    computed: {\n        \n    },\n    components: {\n        subComponent: subComponent\n    },\n    methods: {\n        \n    },\n    watch: {\n        \n    },\n    ready () {\n        \n    }\n}\n\nmvvm = new TinyVue(opts);\n```\n\n这里定义了`\u003csub-component /\u003e`局部组件以及`\u003chello-world /\u003e`全局组件。\n\n## API \n\n### options\n\n* el\n\nType: `String | Node`\n\n根节点选择器或是根节点dom元素。\n\n* template\nType: `String`\n组件模板\n\n* data\n\nType: `Object`\n\n初始化响应式数据模型\n\n* computed\n\nType: `Object`\n\n计算属性，每一个元素对应一个函数\n\n注：\n    * computed属性依赖于data中的响应式数据\n    * computed属性可依赖computed属性\n    * computed禁止赋值操作\n\n* methods\n\nType: `Object`\n每一个元素对应一个函数，支持响应式替换\n\n* watch\n\nType: `Object`\n\n监测对象，监测对应的响应式数据，当数据发生更改时执行回调.\n\n### directives\n    * v-text\n    * v-show\n    * v-visible\n    * v-model\n    * v-on\n    * v-if\n    * v-for\n\n### 实例 api\n\n* $watch\n\nType: `Function`\n监测某一数据的响应式变化\n\n    如：\n    ```js\n    var vm = new TinyVue({\n        data: {\n            info: {\n                age: 18\n            }\n        }\n    });\n    vm.$watch('info', function (info) {\n        \n    });\n\n    vm.$watch('info.age', function (age) {\n        \n    })\n    ```\n\n* $directive\n\nType: `Function`\n\n自定义指令\n\n    如：\n    ```js\n    vm.$directive('text', function (text) {\n        this.el.textContent = text;\n    });\n    ```\n* $reactive\n将一个普通对象转换为一个响应式对象\n\n* component\n定义全局组件\n    ```js\n    TinyVue.component(componentName, opts);\n    ```\n\n* beforeCompiler\n\n生命周期函数，编译前执行\n\n* ready\n\n生命周期函数，渲染完毕后执行\n\n### Install\n\n```js\nnpm install tiny-vue --save\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaofuzi%2Fre-vue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiaofuzi%2Fre-vue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaofuzi%2Fre-vue/lists"}