This file contains hidden or 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 id="app"> | |
<router-link to="/bar">Go to Bar</router-link> | |
<dynamic-link :text="text"></dynamic-link> | |
<router-view></router-view> | |
</div> |
This file contains hidden or 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
<!-- | |
HTML 结构: | |
1. div.box 作为外层居中容器 | |
2. div.content 作为内部居中对象 | |
--> | |
<div class="box"> | |
<div class="content"> | |
content | |
</div> | |
</div> |
This file contains hidden or 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
/* center by traditional relative/absolute position */ | |
/* parent */ | |
.box.box_centerByAbsolute { | |
position: relative; | |
} | |
/* child */ | |
.box.box_centerByAbsolute .content { | |
position: absolute; | |
top: 0; |
This file contains hidden or 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
.box.box_centerByFlex { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
} | |
.box.box_centerByFlex .content { | |
align-self: center; | |
} |
This file contains hidden or 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
.box.box_centerByFlex { | |
display: flex; | |
} | |
.box.box_centerByFlex .content { | |
margin: auto; | |
} |
This file contains hidden or 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 urlString = "https://www.apple.com/cn" | |
let url = URL(string: urlString)! | |
let requestURL = URLRequest(url: url) | |
webview.loadRequest(requestURL) |
This file contains hidden or 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 filePathString = "html/index" | |
let path = Bundle.main.path(forResource: filePathString, ofType: "html") | |
let url = URL(fileURLWithPath: Path)! | |
let requestUrl = URLRequest(url: url) | |
webview.loadRequest(requestURL) |
This file contains hidden or 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
func webViewDidStartLoad(_ webView: UIWebView) { | |
let jsString = "alert('UIWebView Start Loading from local file')" | |
webviewBrowser.stringByEvaluatingJavaScript(from: jsString) | |
} |
This file contains hidden or 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
// 直接 alert | |
function sayHello () { alert('hello') } | |
// alert with parameter | |
function sayHelloTo(name) { alert(`Hello ${name}`) } | |
// alert with parameter & return value | |
function sayHelloWithRtnValue (name) { return `hello ${name}` } |
This file contains hidden or 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
extension ViewController: UIWebViewDelegate { | |
let jsString = "alert('UIWebView Loading from local file')" | |
webviewBrowser.stringByEvaluatingJavaScript(from: jsString) | |
} |