this.state 組件免不了要與用戶互動,React 的一大創新,就是將組件看成是一個狀態機,一開始有一個初始狀態,然後用戶互動,導致狀態變化,從而觸發重新渲染 UI http://www.ruanyifeng.com/blog/2015/03/react.html demo8
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 promise = new Promise((resolve, reject) => { | |
console.log(1); | |
resolve(); | |
console.log(2); | |
reject('error'); | |
}) | |
promise.then(() => { | |
console.log(3); | |
}).catch(e => console.log(e)) | |
console.log(4); |
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> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous"> | |
</head> | |
<body> | |
<div class="card" style="width: 20rem;"> |
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
/** | |
* Flexible background positioning | |
* via extended background-position | |
*/ | |
div { | |
background: url(http://csssecrets.io/images/code-pirate.svg) | |
no-repeat bottom right #58a; | |
background-position: right 20px bottom 10px; | |
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
<style id="jsbin-css"> | |
/* line 5, ../../app/assets/stylesheets/partials/_reset.css.sass */ | |
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, address, cite, code, em, img, strong, sub, sup, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, nav, output, section, time, mark, audio, video { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
font-size: 100%; | |
font: inherit; | |
vertical-align: baseline; | |
} |
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> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<button id="main_button">click me</buttton> | |
<script id="jsbin-javascript"> |
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
<div class="quote-box"> | |
<div class="quote-text"> | |
<i class="fa fa-quote-left"> </i><span id="text"></span> | |
</div> | |
<div class="quote-author"> | |
- <span id="author"></span> | |
</div> | |
<div class="buttons"> | |
<a class="button" id="tweet-quote" title="Tweet this quote!" target="_blank"> |
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
/** | |
* @param {number} n | |
* @return {boolean} | |
*/ | |
var isPowerOfThree = function(n) { | |
return n.toString(3).replace(/0/g, '') === '1'; | |
}; | |
/* | |
Given an integer, write a function to determine if it is a power of three. |
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
<?php | |
$url = 'https://www.microsoft.com/zh-tw/store/apps/facebook/9wzdncrfhv5g'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_HEADER, false); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
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
<?php | |
$ffmpeg_location ='"C:\Program Files\ffmpeg-20140928-git-3edb9aa-win64-static\bin\ffmpeg.exe"'; | |
$file_path = 'C:\\ed2b6a653ded.mp4'; | |
$src_cover = 'C:\src_cover.jpg'; | |
$ffm = $ffmpeg_location . ' -i '. $file_path . ' -ss 00:00:01 -f image2 -vframes 1 ' . $src_cover.' 2>&1'; | |
$xyz = shell_exec($ffm); | |
$search='/Duration: (.*?),/'; | |
preg_match($search, $xyz, $matches); | |
$duration = explode(':', $matches[1]); |
NewerOlder