Skip to content

Instantly share code, notes, and snippets.

View yyx990803's full-sized avatar

Evan You yyx990803

View GitHub Profile
var Example = Vue.extend({
template: '<div>{{ message }}</div>',
data: function () {
return {
message: 'Hello Vue.js!'
}
}
})
// register it with the tag <example>
var example = new Vue({
data: {
a: 1
},
computed: {
b: function () {
return this.a + 1
}
}
})
new Vue({
el: ‘#example’,
data: object
})
<div id=”example”>
{{ message }}
</div>
@yyx990803
yyx990803 / data.js
Last active November 2, 2015 20:17
var object = {
message: 'Hello world!'
}
@yyx990803
yyx990803 / pre-commit.sh
Last active October 22, 2018 20:52
pre-commit hook for Vue.js
#!/usr/bin/env bash
# get files to be linted
FILES=$(git diff --cached --name-only | grep -E '^src|^test/unit/specs|^test/e2e')
# lint them if any
if [[ $FILES ]]; then
./node_modules/.bin/eslint $FILES
fi
@yyx990803
yyx990803 / Material-Theme.tmTheme
Last active August 29, 2015 14:25
Material Theme color scheme modified for JavaScriptNext
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="2.4">
<dict>
<key>author</key>
<string>Mattia Astorino (http:&#x2f;&#x2f;astorinomattia.it)</string>
<key>name</key>
<string>Material Theme</string>
<key>semanticClass</key>
@yyx990803
yyx990803 / bench.js
Created May 31, 2015 04:17
orderBy benchmark
// vue internals
var _ = require('../src/util')
var Path = require('../src/parsers/path')
// original implementation using native sort
var original = function (arr, sortKey, reverse) {
if (!sortKey) {
return arr
}
var order = 1
@yyx990803
yyx990803 / API options
Last active August 29, 2015 14:20
UglifyJS options for minifying Vue application
compress: {
pure_funcs: [
'_.log',
'_.warn',
'_.assertAsset',
'enableDebug'
]
}
var vm = new Vue({
components: {
example: {
data: function () {
return { a: 1 }
}
}
}
})