This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Demo Vue</title> | |
<script src="https://unpkg.com/vue@2.3.0/dist/vue.js"></script> | |
<script src="https://unpkg.com/axios@0.16.1/dist/axios.js"></script> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- app.vue --> | |
<template lang="html"> | |
<div class="message"> | |
{{ message }} | |
{{ ok }} | |
</div> | |
</template> | |
<script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable */ | |
/** | |
* PATTERN 1 | |
**/ | |
module.exports = function() { | |
console.log('Hello world'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Emitter = require('./emitter') | |
let emtr = new Emitter() | |
emtr.on('greet', function () { | |
console.log('Somewhere, someone said hello') | |
}) | |
emtr.on('greet', function () { | |
console.log('A greeting occurred') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Emitter = require('events') | |
const eventsConfig = require('./config').events | |
let emtr = new Emitter() | |
emtr.on(eventsConfig.GREET, function () { | |
console.log('Somewhere, someone said hello') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 使用 util.inherits 來繼承 EventEmitter 的方法 | |
const EventEmitter = require('events') | |
const util = require('util') | |
function Greetr () { | |
// 如果我們想要完整繼承 EventEmitter 中的屬性 | |
EventEmitter.call(this) | |
this.greeting = 'someone greet' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let obj = { | |
name: 'Aaron Chen', | |
greet: function () { | |
console.log(`Hello ${this.name}`) | |
} | |
} | |
obj.greet() | |
obj.greet.call({name: 'Andy Chang'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ./node_modules/passport/lib/middleware/authenticate.js | |
/** | |
* Module dependencies. | |
*/ | |
var http = require('http'), | |
IncomingMessageExt = require('../http/request'), | |
AuthenticationError = require('../errors/authenticationerror') | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = window.superagent; | |
const root = "https://jsonplaceholder.typicode.com"; | |
const postVm = new Vue({ | |
el: "#post", | |
data: { | |
post: { | |
userId: "", | |
id: "", | |
title: "" |