├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── _config.yml ├── assets ├── icons.psd ├── lifecycle.ai ├── logo.ai └── state.ai ├── package.json ├── src ├── CNAME ├── _posts │ ├── 011-component.md │ ├── 012-release.md │ ├── 1.0.0-release.md │ ├── announcing-2.0.md │ ├── common-gotchas.md │ ├── march-update.md │ ├── vue-011-release.md │ ├── vue-cli.md │ ├── vue-next.md │ ├── vuejs-010-release.md │ └── why-no-template-url.md ├── api │ └── index.md ├── blog │ └── index.md ├── examples │ ├── commits.md │ ├── elastic-header.md │ ├── firebase.md │ ├── grid-component.md │ ├── hackernews.md │ ├── index.md │ ├── modal.md │ ├── select2.md │ ├── svg.md │ ├── todomvc.md │ └── tree-view.md ├── guide │ ├── application.md │ ├── class-and-style.md │ ├── comparison.md │ ├── components.md │ ├── computed.md │ ├── conditional.md │ ├── custom-directive.md │ ├── custom-filter.md │ ├── events.md │ ├── forms.md │ ├── index.md │ ├── installation.md │ ├── instance.md │ ├── join.md │ ├── list.md │ ├── mixins.md │ ├── overview.md │ ├── plugins.md │ ├── reactivity.md │ ├── syntax.md │ └── transitions.md ├── images │ ├── components.png │ ├── data.png │ ├── hn.png │ ├── lifecycle.png │ ├── mvvm.png │ ├── state.png │ ├── vue-component-with-pre-processors.png │ └── vue-component.png ├── index.md ├── perf │ └── index.md └── support-vuejs │ └── index.md ├── themes └── vue │ ├── _config.yml │ ├── layout │ ├── index.ejs │ ├── layout.ejs │ ├── page.ejs │ ├── partials │ │ ├── ad.ejs │ │ ├── blog.ejs │ │ ├── community_dropdown.ejs │ │ ├── ga.ejs │ │ ├── header.ejs │ │ ├── main_menu.ejs │ │ ├── sidebar.ejs │ │ └── sponsors.ejs │ └── post.ejs │ └── source │ ├── css │ ├── _blog.styl │ ├── _common.styl │ ├── _demo.styl │ ├── _search.styl │ ├── _settings.styl │ ├── _syntax.styl │ ├── benchmark.styl │ ├── index.styl │ └── page.styl │ ├── images │ ├── chaitin.png │ ├── check.png │ ├── down.png │ ├── feed.png │ ├── htmlburger.png │ ├── icons.png │ ├── itunescn.png │ ├── jsfiddle.png │ ├── juejin.png │ ├── laravel.png │ ├── logo.png │ ├── menu.png │ ├── patreon.png │ ├── paypal.png │ ├── search.png │ ├── someline.png │ └── strikingly.png │ └── js │ ├── common.js │ ├── smooth-scroll.min.js │ ├── vue.js │ └── vue.min.js ├── todomvc ├── index.html ├── js │ ├── app.js │ ├── routes.js │ └── store.js ├── node_modules │ ├── director │ │ └── build │ │ │ └── director.js │ └── todomvc-app-css │ │ └── index.css ├── package.json └── readme.md └── update.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | db.json 4 | *.log 5 | node_modules/ 6 | public/ 7 | .deploy*/ 8 | src/_drafts 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2015 Yuxi Evan You 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: update deploy 2 | 3 | deploy: 4 | rm -f db.json 5 | hexo generate 6 | cp -R ./todomvc public/examples 7 | mkdir -p public/unit 8 | cp -R ../vue/test/unit/lib/ public/unit/lib 9 | cp ../vue/test/unit/index.html public/unit/index.html 10 | cp ../vue/test/unit/specs.js public/unit/specs.js 11 | cp ../vue/test/unit/specs.js.map public/unit/specs.js.map 12 | hexo deploy 13 | 14 | update: 15 | cd ../vue && \ 16 | git checkout -- dist && \ 17 | git checkout master && \ 18 | npm run build && \ 19 | npm run build-test > /dev/null 20 | cp ../vue/dist/vue.min.js themes/vue/source/js/vue.min.js 21 | cp ../vue/dist/vue.js themes/vue/source/js/vue.js 22 | node update.js 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docs.vuejs.id 2 | 3 | Situs ini dibangun dengan [hexo](http://hexo.io/). Konten situs ditulis menggunakan format Markdown yang bertempat di folder `src`. Pull request dipersilakan! 4 | 5 | ## Pengembangan 6 | 7 | Memulai server pengembangan pada `localhost:4000`: 8 | 9 | ``` 10 | $ npm install -g hexo-cli 11 | $ npm install 12 | $ hexo server 13 | ``` 14 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | # Hexo Configuration 2 | ## Docs: http://zespia.tw/hexo/docs/configuration.html 3 | ## Source: https://github.com/tommy351/hexo/ 4 | 5 | # Site 6 | title: Vue.js Indonesia - Documentation 7 | subtitle: 8 | description: "Reactive Components for Modern Web Interfaces" 9 | author: Evan You 10 | email: 11 | language: 12 | 13 | # URL 14 | ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' 15 | url: http://docs.vuejs.id 16 | root: / 17 | permalink: :year/:month/:day/:title/ 18 | tag_dir: tags 19 | archive_dir: archives 20 | category_dir: categories 21 | code_dir: downloads/code 22 | 23 | # Directory 24 | source_dir: src 25 | public_dir: public 26 | 27 | # Writing 28 | new_post_name: :title.md # File name of new posts 29 | default_layout: post 30 | auto_spacing: false # Add spaces between asian characters and western characters 31 | titlecase: false # Transform title into titlecase 32 | external_link: true # Open external links in new tab 33 | max_open_file: 100 34 | multi_thread: true 35 | filename_case: 0 36 | render_drafts: false 37 | post_asset_folder: false 38 | highlight: 39 | enable: true 40 | line_number: false 41 | tab_replace: 42 | 43 | # Category & Tag 44 | default_category: uncategorized 45 | category_map: 46 | tag_map: 47 | 48 | # Archives 49 | ## 2: Enable pagination 50 | ## 1: Disable pagination 51 | ## 0: Fully Disable 52 | archive: 0 53 | category: 0 54 | tag: 0 55 | 56 | # Server 57 | ## Hexo uses Connect as a server 58 | ## You can customize the logger format as defined in 59 | ## http://www.senchalabs.org/connect/logger.html 60 | port: 4000 61 | logger: false 62 | logger_format: 63 | 64 | # Date / Time format 65 | ## Hexo uses Moment.js to parse and display date 66 | ## You can customize the date format as defined in 67 | ## http://momentjs.com/docs/#/displaying/format/ 68 | date_format: MMM D YYYY 69 | time_format: H:mm:ss 70 | 71 | # Pagination 72 | ## Set per_page to 0 to disable pagination 73 | per_page: 10 74 | pagination_dir: page 75 | 76 | # Disqus 77 | disqus_shortname: 78 | 79 | # Extensions 80 | ## Plugins: https://github.com/tommy351/hexo/wiki/Plugins 81 | ## Themes: https://github.com/tommy351/hexo/wiki/Themes 82 | theme: vue 83 | exclude_generator: 84 | 85 | # Markdown 86 | ## https://github.com/chjj/marked 87 | markdown: 88 | gfm: true 89 | pedantic: false 90 | sanitize: false 91 | tables: true 92 | breaks: true 93 | smartLists: true 94 | smartypants: true 95 | 96 | # Deployment 97 | ## Docs: http://zespia.tw/hexo/docs/deployment.html 98 | deploy: 99 | type: git 100 | repository: git@github.com:vuejs-id/docs.git 101 | 102 | feed: 103 | type: atom 104 | path: atom.xml 105 | limit: 20 106 | -------------------------------------------------------------------------------- /assets/icons.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs-id/docs-old/70d670df41229bfbcfd73a6a0c2b1e8844f4eb22/assets/icons.psd -------------------------------------------------------------------------------- /assets/lifecycle.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs-id/docs-old/70d670df41229bfbcfd73a6a0c2b1e8844f4eb22/assets/lifecycle.ai -------------------------------------------------------------------------------- /assets/logo.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs-id/docs-old/70d670df41229bfbcfd73a6a0c2b1e8844f4eb22/assets/logo.ai -------------------------------------------------------------------------------- /assets/state.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuejs-id/docs-old/70d670df41229bfbcfd73a6a0c2b1e8844f4eb22/assets/state.ai -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuejs.org", 3 | "version": "1.0.18", 4 | "private": true, 5 | "hexo": { 6 | "version": "3.2.2" 7 | }, 8 | "dependencies": { 9 | "hexo": "^3.2.0", 10 | "hexo-deployer-git": "0.1.0", 11 | "hexo-generator-archive": "^0.1.4", 12 | "hexo-generator-category": "^0.1.3", 13 | "hexo-generator-feed": "^1.1.0", 14 | "hexo-generator-index": "^0.2.0", 15 | "hexo-generator-tag": "^0.2.0", 16 | "hexo-renderer-ejs": "^0.2.0", 17 | "hexo-renderer-marked": "^0.2.10", 18 | "hexo-renderer-stylus": "^0.3.1", 19 | "hexo-server": "^0.2.0" 20 | } 21 | } -------------------------------------------------------------------------------- /src/CNAME: -------------------------------------------------------------------------------- 1 | docs.vuejs.id 2 | -------------------------------------------------------------------------------- /src/_posts/011-component.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 0.11 Component Tips 3 | date: 2014-12-08 15:02:14 4 | tags: 5 | --- 6 | 7 |

Note: this post contains information for the outdated 0.11 version. Please refer to the [0.12 release notes](https://github.com/yyx990803/vue/releases) for the changes in the API.

8 | 9 | The release of 0.11 introduced [many changes](https://github.com/yyx990803/vue/blob/master/changes.md), but the most important one is how the new component scope works. Previously in 0.10.x, components have inherited scope by default. That means in a child component template you can reference parent scope properties. This often leads to tightly-coupled components, where a child component assumes knowledge of what properties are present in the parent scope. It is also possible to accidentally refer to a parent scope property in a child component. 10 | 11 | 12 | 13 | ### Isolated Scope and Data Passing 14 | 15 | Starting in 0.11, all child components have isolated scope by default, and the recommended way to control component data access is via [Explicit Data Passing](/guide/components.html#Explicit_Data_Passing) using [`v-with`](/api/directives.html#v-with) or [`paramAttributes`](/api/options.html#paramAttributes). 16 | 17 | `paramAttributes` enables us to write Web Component style templates: 18 | 19 | ``` js 20 | Vue.component('my-component', { 21 | paramAttributes: ['params'], 22 | compiled: function () { 23 | console.log(this.params) // passed from parent 24 | } 25 | }) 26 | ``` 27 | 28 | ``` html 29 | 30 | ``` 31 | 32 | ### Where Does It Belong? 33 | 34 | Previously in 0.10, all directives on a component's container element are compiled in the child component's scope. Because it inherited parent scope, this worked in most situations. Starting in 0.11.1, we want to provide a cleaner separation between component scopes. The rule of thumbs is: if something appears in the parent template, it will be compiled in parent scope; if it appears in child template, it will be compiled in child scope. For example: 35 | 36 | ``` html 37 | 38 |
39 |

{{parentMessage}}

40 |
41 | ``` 42 | 43 | ``` html 44 | 45 |
46 |

{{childMessage}}

47 | 48 |
49 | ``` 50 | 51 | Everything in the parent template will be compiled in the parent's scope, including the content that's going to be inserted into the child component. 52 | 53 | The only exception to the rule is `v-with` (and `paramAttributes` which compiles down to `v-with`), which works in both places - so you don't need to worry about it too much. 54 | 55 | ### Cleaner Event Communication 56 | 57 | Previously the standard way for a child component to communicate to its parent is via dispatching events. However, with this approach, the event listeners on the parent component are not guaranteed to be listening on the desired child component only. It's also possible to trigger undesired listners further up the chain if we do not cancel the event. 58 | 59 | The most common use case is for a parent to react to the events from a specific, direct child component. So in 0.11.4, [a new directive `v-events`](/api/directives.html#v-events) has been introduced to enable exactly this behavior. 60 | 61 | 0.11.4 has already been released, go try it out! 62 | -------------------------------------------------------------------------------- /src/_posts/012-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Vue.js 0.12 released! 3 | date: 2015-06-11 17:37:30 4 | --- 5 | 6 | I'm really excited to announce that [Vue.js 0.12: Dragon Ball](https://github.com/yyx990803/vue/releases/tag/0.12.0) is finally here! Thanks to everyone who tried out the beta/rc versions and provided feedback / bug reports along the way. 7 | 8 | There's a lot to cover in this release, and we will talk about a few highlights below. However, it is still recommended to carefully go through the [Full Release Note](https://github.com/yyx990803/vue/releases/tag/0.12.0) and updated docs if you are upgrading from 0.11. You can report bugs on GitHub, send questions to [vuejs/Discussion](https://github.com/vuejs/Discussion/issues), or join us in the [Gitter chat channel](https://gitter.im/yyx990803/vue). 9 | 10 | 11 | 12 | ### More Consistent Component Syntax 13 | 14 | Previously in 0.11 you have two ways to use a Vue.js component: using the `v-component` directive, or using custom elements. There are also two ways to pass data down to child components: using the `v-with` directive, or using the `paramAttributes` option. Although both custom elements and param attributes get compiled down to directives eventually, it is confusing and redundant to have two sets of syntax for the same functionality. 15 | 16 | In addition, it should be noted that the component system is a first-class concept in Vue.js, even more important than directives. It defines how we encapsulate our higher-level view logic and compose our application. In the meanwhile, having a clear and declarative way to pass data into child components is also very important. Components and param attributes really deserve their own dedicated syntax to differentiate from other directives. 17 | 18 | As a result, `v-component` and `v-with` have been deprecated in 0.12. `paramAttributes` has also been renamed to `props`, which is shorter and cleaner. From now on, most Vue.js components will look like this: 19 | 20 | ``` html 21 | 22 | ``` 23 | 24 | There are also additional props-related improvements such as explicit one-time or one-way props, expression as props, methods as prop callbacks and more. You can find out more details in the 0.12 release notes linked above and the updated [Component System](/guide/components.html) section of the guide. 25 | 26 | ### Filter Arguments Improvements 27 | 28 | In 0.11, filters always receive their arguments as plain strings. An argument can be enclosed in quotes to include whitespace, but the quotes are not automatically stripped when passed into the filter function. Some users were also confused about how to retrive a dynamic value on the vm instead of a plain string. 29 | 30 | In 0.12, the filter argument syntax now follows a simple rule: if an argument is enclosed in quotes, it will be passed in as a plain string; otherwise, it will be evaluated against the current vm as a dynamic value. 31 | 32 | This means the usage of some existing filters will have to change: 33 | 34 | ``` html 35 | 36 | {{ items.length | pluralize 'item' }} 37 | ``` 38 | 39 | But it would make custom filters that rely on dynamic values much easier to write: 40 | 41 | ``` html 42 | {{ msg | concat otherMsg }} 43 | ``` 44 | 45 | Here the first argument to the `concat` filter will be the value of `this.otherMsg`. 46 | 47 | ### Asynchronous Components 48 | 49 | It is common practice to bundle all the JavaScript into one file when building large single page applications. But when the file becomes too large, we may want to defer loading parts of our application for a faster initial load. However, this does pose some constraints on how the application architecture should be designed. It could be very tricky to figure out how to properly split up your JavaScript bundles. 50 | 51 | Well, with Vue.js we can already build our applications as decoupled components. If we can lazily load a dynamic component only when it is needed, wouldn't it be awesome? As a matter of fact, in 0.12 this would be trivially easy with the new Asynchronous Component feature. 52 | 53 | In 0.12, you can define a component as a factory function that asynchronously resolves a component definition (can be just a plain options object). Vue.js will only trigger the factory function when the component actually needs to be rendered, and will cache the result for future re-renders: 54 | 55 | ``` js 56 | Vue.component('async-example', function (resolve, reject) { 57 | setTimeout(function () { 58 | resolve({ 59 | template: '
I am async!
' 60 | }) 61 | }, 1000) 62 | }) 63 | ``` 64 | 65 | It is up to you to decide how to load the component from the server, e.g. `$.getScript()` or require.js; but the recommended usage is to pair it up with Webpack's [Code Splitting feature](http://webpack.github.io/docs/code-splitting.html): 66 | 67 | ``` js 68 | Vue.component('async-webpack-example', function (resolve, reject) { 69 | // In Webpack AMD like syntax indicates a code split point 70 | require(['./my-async-component'], resolve) 71 | }) 72 | ``` 73 | 74 | That's all you need to do. You can use the component just like before, without even thinking about it being async. Webpack will automatically split your final JavaScript into separate bundles with correct dependencies, and automatically load a bundle via Ajax when it is required. You can check out a fully functional example [here](https://github.com/vuejs/vue-webpack-example). 75 | 76 | ### Improved Transition System 77 | 78 | Vue.js' transition system is really easy to use, but in the past it has the limitation that you cannot mix CSS and JavaScript-based transitions together. In 0.12 that is no longer the case! The improved transition system now allows you to add JavaScript hooks to a CSS-based transition for additional control. The amount of hooks exposed have also been expanded to give you finer-grained control at every stage of the transition. 79 | 80 | `v-repeat` now also ships with built-in support for staggering transitions. It is as simple as adding `stagger="100"` to your repeated element. It is also possible to define separate staggering for enter and leaving, or even dynamically calculate the staggering delay in a JavaScript hook. 81 | 82 | For full details on the new transition system, check out the [updated guide](/guide/transitions.html). 83 | 84 | ### Performance Tuning 85 | 86 | Vue.js' precise dependency tracking makes it the one of the most efficient view layer for small hot updates, but there's always room for improvement. In 0.12, internal instance creation and compilation refactors have improved first-render performance for large lists by up to 40%. With proper `track-by` usage, [re-rendering with large, brand new dataset](http://vuejs.github.io/js-repaint-perfs/vue/) is also comparable to, or even faster than other Virtual-DOM based frameworks. 87 | 88 | ### One More Thing... 89 | 90 | With 0.12 out of the door, more efforts will now be spent on the official vue-router, a dedicated routing library for Vue.js with nested view matching, full transition support, and asynchronous data hooks. I have expressed that Vue.js core intends to stay as a no-frills, drop-in view layer library, and that will not change. The vue-router will be shipped separately and is totally optional, however you can expect it to work seamlessly with Vue.js core when you need it. 91 | -------------------------------------------------------------------------------- /src/_posts/1.0.0-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Vue.js 1.0.0 Released 3 | date: 2015-10-26 10:00:00 4 | --- 5 | 6 | > Hi HN! If you are not familiar with Vue.js, you might want to read this [blog post](http://blog.evanyou.me/2015/10/25/vuejs-re-introduction/) for a higher level overview. 7 | 8 | After 300+ commits, 8 alphas, 4 betas and 2 release candidates, today I am very proud to announce the release of [Vue.js 1.0.0 Evangelion](https://github.com/vuejs/vue/releases/tag/1.0.0)! Many thanks to all those who participated in the API re-design process - it would not have been possible without all the input from the community. 9 | 10 | 11 | 12 | ### Improved Template Syntax 13 | 14 | The 1.0 template syntax resolves a lot of subtle consistency issues and makes Vue templates more concise and more readable in general. The most notable new feature is the shorthand syntax for `v-on` and `v-bind`: 15 | 16 | ``` html 17 | 18 | 19 | 20 | 21 | 22 | ``` 23 | 24 | When used on a child component, `v-on` listens for custom events and `v-bind` can be used to bind props. The shorthands using child components very succinct: 25 | 26 | ``` html 27 | 31 | 32 | ``` 33 | 34 | ### API Cleanup 35 | 36 | The overall goal for Vue.js 1.0 is to make it suitable for larger projects. This is why there are many API deprecations. Except for ones that are barely used, the most common reason for a deprecation is that the feature leads to patterns that damages maintainability. Specifically, we are deprecating features that make it hard to maintain and refactor a component in isolation without affecting the rest of the project. 37 | 38 | For example, the default asset resolution in 0.12 has implicit fallbacks to parents in the component tree. This makes the assets available to a component non-deterministic and subject how it is used at runtime. In 1.0, all assets are now resolved in strict mode and there are no longer implicit fallbacks to parent. The `inherit` option is also removed, because it too often leads to tightly coupled components that are hard to refactor. 39 | 40 | ### Faster Initial Rendering 41 | 42 | 1.0 replaces the old `v-repeat` directive with `v-for`. In addition to providing the same functionality and more intuitive scoping, `v-for` provides up to **100%** initial render performance boost when rendering large lists and tables! 43 | 44 | ### More Powerful Tooling 45 | 46 | There are also exciting things going on outside of Vue.js core - [vue-loader](https://github.com/vuejs/vue-loader) and [vueify](https://github.com/vuejs/vueify) have received major upgrades including: 47 | 48 | - Hot component reloading. When a `*.vue` component is edited, all of its active instances are hot swapped without reloading the page. This means when making small changes, e.g. tweaking the styles or the template, your app doesn't need to fully reload; the state of the app the swapped component can be preserved, drastically improving the development experience. 49 | 50 | - Scoped CSS. By simply adding a `scoped` attribute to your `*.vue` component style tags, the component's template and final generated CSS are magically re-written to ensure a component's styles are only applied to its own elements. Most importantly, the styles specified in a parent component **does not** leak down to child components nested within it. 51 | 52 | - ES2015 by default. JavaScript is evolving. You can write much cleaner and expressive code using the latest syntax. `vue-loader` and `vueify` now transpiles the JavaScript in your `*.vue` components out of the box, without the need for extra setup. Write future JavaScript today! 53 | 54 | Combined with [vue-router](https://github.com/vuejs/vue-router), Vue.js is now more than a library - it provides a solid foundation for building complex SPAs. 55 | 56 | ### What's Next? 57 | 58 | As what 1.0.0 usually suggests, the core API will stay stable for the foreseeable future and the library is ready for production use. Future development will focus on: 59 | 60 | 1. Improving `vue-router` and make it production ready. 61 | 62 | 2. Streamlining the developer experience, e.g. a better devtool and a CLI for scaffolding Vue.js projects and components. 63 | 64 | 3. Providing more learning resources such as tutorials and examples. 65 | -------------------------------------------------------------------------------- /src/_posts/announcing-2.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Announcing Vue.js 2.0 3 | date: 2016-04-27 13:33:00 4 | --- 5 | 6 | Today I am thrilled to announce the first public preview of Vue.js 2.0, which brings along many exciting improvements and new features. Let's take a peek at what's in store! 7 | 8 | 9 | 10 | ## Even Leaner, Even Faster 11 | 12 | Vue.js has always focused on staying light and fast, but 2.0 pushes it even further. The rendering layer is now based on a lightweight virtual-DOM implementation (based on [Snabbdom](https://github.com/paldepind/snabbdom)) that improves initial rendering speed and memory consumption by up to 2~4x in most scenarios (check out [these benchmarks](https://github.com/vuejs/vue/tree/next/benchmarks)). The template-to-virtual-DOM compiler and the runtime can be separated, so you can pre-compile templates and ship your app with only the runtime, which is less than 12kb min+gzip (as a reference, React 15 is 44kb min+gzip). The compiler also works in the browser, which means you can still drop in one script tag and start hacking, just like before. Even with the compiler included, the build is sitting at 17kb min+gzip, still lighter than the current 1.0 build. 13 | 14 | ## Not Your Average Virtual-DOM 15 | 16 | Now, just virtual-DOM sounds boring because there are so many implementations out there - but this one is different. Combined with Vue's reactivity system, it provides optimized re-rendering out of the box without you having to do anything. Each component keeps track of its reactive dependencies during its render, so the system knows precisely when to re-render, and which components to re-render. No need for `shouldComponentUpdate` or immutable data structures - **it just works**. 17 | 18 | In addition, Vue 2.0 applies some advanced optimizations during the template-to-virtual-DOM compilation phase: 19 | 20 | 1. It detects static class names and attributes so that they are never diffed after the initial render. 21 | 22 | 2. It detects the maximum static sub trees (sub trees with no dynamic bindings) and hoist them out of the render function. So on each re-render, it directly reuses the exact same virtual nodes and skips the diffing. 23 | 24 | These advanced optimizations can usually only be achieved via Babel plugins when using JSX, but with Vue 2.0 you can get them even using the in-browser compiler. 25 | 26 | The new rendering system also allows you to disable reactive conversions by simply freezing your data and manually force updates, essentially giving you full control over the re-rendering process. 27 | 28 | With these techniques combined, Vue 2.0 ensures blazing fast performance in every possible scenario while requiring minimal optimization efforts from the developer. 29 | 30 | ## Templates, JSX, or Hyperscript? 31 | 32 | Developers tend to have strong opinions on templates vs. JSX. On the one hand, templates are closer to HTML - they map better to the semantic structure of your app and make it much easier to think visually about the design, layout and styling. On the other hand, templates are limited to the DSL while the programmatic nature of JSX/hyperscript provides the full expressive power of a turing-complete language. 33 | 34 | Being a designer/developer hybrid, I prefer writing most of my interfaces in templates, but in certain cases I do miss the flexibility of JSX/hyperscript. An example would be writing a component that programmatically handles its children, something not feasible with just the template-based slot mechanism. 35 | 36 | Well, why not have both? In Vue 2.0, you can keep using the familiar template syntax, or drop down to the virtual-DOM layer whenever you feel constrained by the template DSL. Instead of the `template` option, just replace it with a `render` function. You can even embed render functions in your templates using the special `` tag! The best of both worlds, in the same framework. 37 | 38 | ## Streaming Server-side Rendering 39 | 40 | With the migration to virtual-DOM, Vue 2.0 naturally supports server-side rendering with client-side hydration. One pain point of current mainstream server rendering implementations, such as React's, is that the rendering is synchronous so it can block the server's event loop if the app is complex. Synchronous server-side rendering may even adversely affect time-to-content on the client. Vue 2.0 provides built-in streaming server-side rendering, so that you can render your component, get a readable stream back and directly pipe it to the HTTP response. This ensures your server is responsive, and gets the rendered content to your users faster. 41 | 42 | ## Unlocking More Possibilities 43 | 44 | With the new architecture, there are even more possibilities to explore - for example, rendering to native interfaces on mobile. Currently, we are exploring a port of Vue.js 2.0 that uses [weex](http://alibaba.github.io/weex/) as a native rendering backend, a project maintained by engineers at Alibaba Group, the biggest tech enterprise of China. It is also technically feasible to adapt Vue 2.0's virtual-DOM to run inside ReactNative. We are excited to see how it goes! 45 | 46 | ## Compatibility and What to Expect Next 47 | 48 | Vue.js 2.0 is still in pre-alpha, but you can checkout the source code [here](https://github.com/vuejs/vue/tree/next/). Despite being a full rewrite, the API is largely compatible with 1.0 with the exception of some intentional deprecations. Check out [the same official examples written in 2.0](https://github.com/vuejs/vue/tree/next/examples) - you will see that not much has changed! 49 | 50 | The feature deprecations are part of our continued effort to provide the simplest API possible for maximum developer productivity. You can check out a 1.0 vs. 2.0 feature comparison [here](https://github.com/vuejs/vue/wiki/2.0-features). This does mean that it will take some effort to migrate an existing app if you happen to use some of these deprecated features heavily, but we will provide detailed upgrade guides in the future. 51 | 52 | There is still much work left to be done. We will be releasing the first alpha once we reach satisfactory test coverage, and we are aiming for beta by end of May / early June. In addition to more tests, we also need to update the supporting libraries (vue-router, Vuex, vue-loader, vueify...). Currently only Vuex works with 2.0 out of the box, but we will make sure that everything works smoothly together when 2.0 ships. 53 | 54 | We are also not forgetting about 1.x! 1.1 will be released alongside 2.0 beta, with an LTS period of 6-month critical bug fixes and 9-month security updates. It will also ship with optional deprecation warnings to get you prepared for upgrading to 2.0. Stay tuned! 55 | -------------------------------------------------------------------------------- /src/_posts/common-gotchas.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Common Beginner Gotchas 3 | date: 2016-02-06 10:00:00 4 | --- 5 | 6 | There are few types of questions that we frequently see from users who are new to Vue.js. Although they are all mentioned somewhere in the guide, they are easy to miss and can be hard to find when you do get bitten by the gotchas. Therefore we are aggregating them in this post and hopefully it can save you some time! 7 | 8 | 9 | 10 | ### Why isn't the DOM updating? 11 | 12 | Most of the time, when you change a Vue instance's data, the view updates. But there are two edge cases: 13 | 14 | 1. When you are **adding a new property** that wasn't present when the data was observed. Due to the limitation of ES5 and to ensure consistent behavior across browsers, Vue.js cannot detect property addition/deletions. The best practice is to always declare properties that need to be reactive upfront. In cases where you absolutely need to add or delete properties at runtime, use the global [`Vue.set`](/api/#Vue-set) or [`Vue.delete`](/api/#Vue-delete) methods. 15 | 16 | 2. When you modify an Array by directly setting an index (e.g. `arr[0] = val`) or modifying its `length` property. Similarly, Vue.js cannot pickup these changes. Always modify arrays by using an Array instance method, or replacing it entirely. Vue provides a convenience method `arr.$set(index, value)` which is just syntax sugar for `arr.splice(index, 1, value)`. 17 | 18 | Further reading: [Reactivity in Depth](/guide/reactivity.html) and [Array Change Detection](http://vuejs.org/guide/list.html#Array-Change-Detection). 19 | 20 | ### When is the DOM updated? 21 | 22 | Vue.js uses an asynchronous queue to batch DOM updates. This means when you modify some data, the DOM updates do not happen instantly: they are applied asynchronously when the queue is flushed. So how do you know when the DOM has been updated? Use `Vue.nextTick` right after you modify the data. The callback function you pass to it will be called once the queue has been flushed. 23 | 24 | Further reading: [Async Update Queue](/guide/reactivity.html#Async-Update-Queue). 25 | 26 | ### Why does `data` need to be a function? 27 | 28 | In the basic examples, we declare the `data` directly as a plain object. This is because we are creating only a single instance with `new Vue()`. However, when defining a **component**, `data` must be declared as a function that returns the initial data object. Why? Because there will be many instances created using the same definition. If we still use a plain object for `data`, that same object will be **shared by reference** across all instance created! By providing a `data` function, every time a new instance is created, we can simply call it to return a fresh copy of the initial data. 29 | 30 | Further reading: [Component Option Caveats](/guide/components.html#Component-Option-Caveats). 31 | 32 | ### HTML case insensitivity 33 | 34 | All Vue.js templates are valid, parsable HTML markup, and Vue.js relies on spec-compliant parsers to process its templates. However, as specified in the standard, HTML is case-insensitive when matching tag and attribute names. This means camelCase attributes like `:myProp="123"` will be matched as `:myprop="123"`. As a rule of thumb, you should use camelCase in JavaScript and kebab-case in templates. For example a prop defined in JavaScript as `myProp` should be bound in templates as `:my-prop`. 35 | 36 | Further reading: [camelCase vs. kebab-case](http://vuejs.org/guide/components.html#camelCase-vs-kebab-case). 37 | 38 | We are also discussing the possibility of eliminating this inconsistency by resolving props and components in a case-insensitive manner. Join the conversation [here](https://github.com/vuejs/vue/issues/2308). 39 | -------------------------------------------------------------------------------- /src/_posts/march-update.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: March 2016 Update 3 | date: 2016-03-14 18:45:00 4 | --- 5 | 6 | ## Growing Community 7 | 8 | Vue's growth in the past year has been nothing short of amazing. As of today we are at over 15,000 stars on GitHub, over 500k downloads from npm, and over 2,000 users in the Gitter channel. What's more exciting though, is that the community successfully organized the first [London Vue.js Meetup](http://www.meetup.com/London-Vue-js-Meetup/) and the first [Paris Vue.js Meetup](http://www.meetup.com/Vuejs-Paris/?scroll=true)! A big shoutout to the awesome organizers: [Jack](https://twitter.com/JackBarham), [James](https://twitter.com/onejamesbrowne/) and [Eduardo](https://twitter.com/posva/). 9 | 10 | 11 | 12 | If you are interested in connecting with Vue.js users near you and share your experiences in using Vue.js, joining a local Meetup is a great idea - even better, maybe you can organize one :) 13 | 14 | ## Cool Things Being Built 15 | 16 | More and more amazing things are being built with Vue. There are products like [PageKit](https://pagekit.com/), Laravel Spark (coming soon) and [Statamic](https://v2.statamic.com/), sleek apps like [Koel](http://koel.phanan.net/) and [Gokotta](https://github.com/Zhangdroid/Gokotta), UI components like [VueStrap](http://yuche.github.io/vue-strap/) and [Vue-MDL](http://posva.net/vue-mdl/), and smooth, interactive experiences like [YouTube Adblitz](https://adblitz.withyoutube.com) and even the [Facebook NewsFeed Marketing Site](https://newsfeed.fb.com/)! 17 | 18 | There are many other great projects - too many to be listed here - but you can check them all out in [awesome-vue](https://github.com/vuejs/awesome-vue). If you've built great things with Vue, you should also add them to the list! 19 | 20 | ## A New Vision For the Project 21 | 22 | Some of you may have noticed that the development on the Vue.js core repo has slowed down lately - in the meanwhile, a lot of efforts went into other sub projects, namely [Vuex](https://github.com/vuejs/vuex), [vue-devtools](https://github.com/vuejs/vue-devtools) and the official [Webpack project boilerplate](https://github.com/vuejs-templates/webpack). The next step is a new release for [vue-router](https://github.com/vuejs/vue-router), and better documentation/examples demonstrating how Vue.js core, Vuex and vue-router work together in a large single page application. 23 | 24 | All this adds together towards a new vision for the Vue.js project: a progressive framework that can adapt to different complexity levels. Vue.js core will remain "just the view layer" - you can still drop it on whatever existing page to replace jQuery, but the Vue.js project also includes other pieces like vue-router, Vuex, vue-loader/vueify and vue-cli that works together as a more complete, opinionated framework for single page applications. More on this in a later post. 25 | 26 | ## Vue.js needs your help! 27 | 28 | Open source is awesome, and I'm proud that Vue.js is helping people build real products all over the world. However, as the scope of the project grows, pushing new features while maintaining everything becomes a very demanding job. The good news is you can help! 29 | 30 | ### Looking for collaborators 31 | 32 | There are already users who frequently helps out in various ways, but this is an invitation to make things official. I'm looking for contributors to join the "team", which is currently mostly just me. If that sounds interesting to you, take a look at the application [here](https://docs.google.com/forms/d/1SgDgKZqyivEf5xl0EOWNfs68Xy3f4oBzLXIlwlS0BIs/viewform). 33 | 34 | ### Looking for sponsors 35 | 36 | Another way to help making Vue development sustainable is providing direct financial support. The more financial support I receive, the more time I get to spend on making Vue even better. 37 | 38 | If you run a business and is using Vue in a revenue-generating product, it would make business sense to sponsor Vue development: it ensures the project that your product relies on stays healthy and actively maintained. It can also help your exposure in the Vue community and makes it easier to attract Vue developers. 39 | 40 | If you are an individual user and have enjoyed the productivity of using Vue, consider donating as a sign of appreciation - like buying me coffee once in a while :) 41 | 42 | In either case, you can provide recurring funding through Vue's [Patreon campaign](https://www.patreon.com/evanyou), or provide one-time donations via [PayPal](https://www.paypal.me/evanyou). There are many ideas for Vue that I have lined up but haven't had the time to embark on, and I would love to be able to work on them full time - I hope you can help me make that happen! 43 | -------------------------------------------------------------------------------- /src/_posts/vue-011-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Vue.js 0.11 released! 3 | date: 2014-11-09 09:23:40 4 | --- 5 | 6 | After the long wait, [Vue.js 0.11 **Cowboy Bebop**](https://github.com/yyx990803/vue/releases/tag/0.11.0) is finally here! Thanks to everyone who tried out the release candidate versions and provided feedback / bug reports along the way. 7 | 8 | 9 | 10 | The 0.11 release introduced many new features and also a fair number of breaking changes, so please carefully read through the [0.11 Change List](https://github.com/yyx990803/vue/blob/master/changes.md) before upgrading. Aside from the API changes, 0.11 also ships with better [code quality](https://codeclimate.com/github/yyx990803/vue) and [test coverage](https://coveralls.io/r/yyx990803/vue), and is considerably more robust in almost every aspect. 11 | 12 | This documentation site has been fully upgraded to match the new 0.11 API. For the now legacy 0.10.6 version, you can still find documentations for it at [legacy.vuejs.org](http://legacy.vuejs.org). 13 | -------------------------------------------------------------------------------- /src/_posts/vue-cli.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Announcing vue-cli 3 | date: 2015-12-28 00:00:00 4 | --- 5 | 6 | Recently there has been a lot of [discussion around the tooling hurdle](https://medium.com/@ericclemmons/javascript-fatigue-48d4011b6fc4#.chg95e5p6) when you start a React project. Luckily for Vue.js, all you need to do to start with a quick prototype is including it from a CDN via a ` 54 | {% endraw %} 55 | 56 | 57 | Di sini kita mendeklarasikan sebuah computed property `b`. Fungsi yang kami sediakan akan digunakan sebagai getter function untuk property `vm.b`: 58 | 59 | ``` js 60 | console.log(vm.b) // -> 2 61 | vm.a = 2 62 | console.log(vm.b) // -> 3 63 | ``` 64 | 65 | 66 | Anda dapat membuka console dan bermain dengan contoh vm yang Anda buat sendiri. Value dari `vm.b` selalu bergantung pada value dari `vm.a` 67 | 68 | 69 | Anda dapat melakukan data-bind untuk computed property di dalam template seperti property normal biasa. Vue.js tahu bahwa `vm.b` tergantung pada `vm.a`, jadi ia akan meng-update setap binding yang bergantung pada `vm.b` ketika value `vm.a` berubah. Dan bagian terbaiknya adalah kita membuat dependency relationship (ketergantungan yang saling berhubungan) ini secara deklaratif: computed getter function murni dan tanpa efek samping, yang mana hal tersebut membuatnya menjadi mudah digunakan. 70 | 71 | ### Computed Property vs. $watch 72 | 73 | 74 | Vue.js juga menyediakan method API yang bernama `$watch` yang mengizinkan Anda untuk mengamati perubahan data pada Vue instance. Ketika Anda memiliki beberapa data yang perlu berubah berdasarkan data yang lain, cobalah untuk menggunakan `$watch` - terutama jika Anda sebelumnya sudah terbiasa dengan AngularJS. Bagaimanapun, merupakan ide yang bagus untuk menggunakan computed property daripada menggunakan `$watch` callback yang impoeratif itu. Perhatikan contoh berikut: 75 | 76 | ``` html 77 |
{{fullName}}
78 | ``` 79 | 80 | ``` js 81 | var vm = new Vue({ 82 | el: '#demo', 83 | data: { 84 | firstName: 'Foo', 85 | lastName: 'Bar', 86 | fullName: 'Foo Bar' 87 | } 88 | }) 89 | 90 | vm.$watch('firstName', function (val) { 91 | this.fullName = val + ' ' + this.lastName 92 | }) 93 | 94 | vm.$watch('lastName', function (val) { 95 | this.fullName = this.firstName + ' ' + val 96 | }) 97 | ``` 98 | 99 | 100 | Kode di atas adalah kode yang impoeratif dan repetitif. Bandingkan dengan versi computed property seperti di bawah ini: 101 | 102 | ``` js 103 | var vm = new Vue({ 104 | el: '#demo', 105 | data: { 106 | firstName: 'Foo', 107 | lastName: 'Bar' 108 | }, 109 | computed: { 110 | fullName: function () { 111 | return this.firstName + ' ' + this.lastName 112 | } 113 | } 114 | }) 115 | ``` 116 | 117 | 118 | Lebih baik, bukan? 119 | 120 | ### Computed Setter 121 | 122 | 123 | Computed properties pada mulanya hanyalah sebuah getter (getter-only), akan tetapi Anda juga dapat menyediakan sebuah setter ketika membutuhkannya: 124 | 125 | ``` js 126 | // ... 127 | computed: { 128 | fullName: { 129 | // getter 130 | get: function () { 131 | return this.firstName + ' ' + this.lastName 132 | }, 133 | // setter 134 | set: function (newValue) { 135 | var names = newValue.split(' ') 136 | this.firstName = names[0] 137 | this.lastName = names[names.length - 1] 138 | } 139 | } 140 | } 141 | // ... 142 | ``` 143 | 144 | 145 | Sekarang ketika Anda memanggil `vm.fullName = 'John Doe'`, setter tersebut akan terpanggil dan `vm.firstName` dan `vm.lastName`juga akan ikut terbaharui. 146 | 147 | 148 | Detil teknis dibalik cara kerja computed property [didiskusikan halaman yang lain](reactivity.html#Inside-Computed-Properties) yang membahas tentang reactivity system (sistem reaktifitas). 149 | -------------------------------------------------------------------------------- /src/guide/conditional.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Conditional Rendering 3 | type: guide 4 | order: 7 5 | --- 6 | 7 | ## v-if 8 | 9 | 10 | Pada string templates, sebagai contoh Handlebars, kita akan menulis sebuah blok kondisional seperti ini: 11 | 12 | ``` html 13 | 14 | {{#if ok}} 15 |

Yes

16 | {{/if}} 17 | ``` 18 | 19 | 20 | Pada Vue.js, kita menggunakan `v-if` directive untuk mendapatkan hal yang sama: 21 | 22 | ``` html 23 |

Yes

24 | ``` 25 | 26 | 27 | Memungkinkan juga untuk menambahkan blok "else" dengan `v-else`: 28 | 29 | ``` html 30 |

Yes

31 |

No

32 | ``` 33 | 34 | ## Template v-if 35 | 36 | 37 | Karena `v-if` adalah sebuah directive, dia harus terikat dengan sebuah elemen tunggal. Tetapi, bagaimana jika kita ingin men-toggle lebih dari satu elemen? Dalam kasus ini kita bisa menggunakan `v-if` pada sebuah elemen `