Laravel 是一个具有很强控制反转(IoC)与依赖注入(DI)能力的容器。不幸的是它的官方文档没有更详细的介绍这些用法,所以我决定自己做点试验并写些更详细的文档。下面所有的都是基于Laravel 5.4.26,不同版本可能有异。
我不会在这里介绍DI/IoC的原理,如果对依赖注入与控制反转不是很熟悉,你可以阅读这篇文章 What is Dependency Injection?
| (function webpackUniversalModuleDefinition(root, factory) { | |
| if(typeof exports === 'object' && typeof module === 'object') | |
| module.exports = factory(require("JSZip")); | |
| else if(typeof define === 'function' && define.amd) | |
| define(["JSZip"], factory); | |
| else if(typeof exports === 'object') | |
| exports["ePub"] = factory(require("JSZip")); | |
| else | |
| root["ePub"] = factory(root["JSZip"]); | |
| })(window, function(__WEBPACK_EXTERNAL_MODULE__29__) { |
| // ==UserScript== | |
| // @name Redirect Wiki Mobile to Desktop UI | |
| // @name:zh-CN 移动端维基重定向到桌面端 | |
| // @namespace https://hawu.me | |
| // @version 0.1 | |
| // @description Redirect wiki mobile version to desktop version. Auto redirect or Offer a hyperlink on the top of mobile version page. | |
| // @description:zh-CN 将维基百科的移动端页面重定向到桌面端(两种方式:自动重定向 或 在移动端页首增加桌面端的跳转链接) | |
| // @author funway | |
| // @match https://zh.m.wikipedia.org/* | |
| // @icon https://zh.wikipedia.org/favicon.ico |
| import SwiftUI | |
| struct TimerTest: View { | |
| @State var date = Date() | |
| @State var showSubView = false | |
| var windowDelegate: MyWindowDelegate = MyWindowDelegate() | |
| var body: some View { | |
| ZStack{ | |
| if showSubView { |
| import SwiftUI | |
| struct TimerTest: View { | |
| @State var showSubView = false | |
| @State var date1 = Date() | |
| @State var timer1 = Timer.publish(every: 1, on: .main, in: .common).autoconnect() | |
| weak var myWindow: NSWindow? | |
| // In AppDelegate.swift, use "let contentView = TimerTest(myWindow: window)" | |
| var body: some View { |
| import SwiftUI | |
| struct TimerTest: View { | |
| @State var date = Date() | |
| @State var showSubView = false | |
| @State var timer: Timer? | |
| @State var date1 = Date() | |
| @State var timer1 = Timer.publish(every: 1, on: .main, in: .common).autoconnect() | |
| var body: some View { |
Laravel 是一个具有很强控制反转(IoC)与依赖注入(DI)能力的容器。不幸的是它的官方文档没有更详细的介绍这些用法,所以我决定自己做点试验并写些更详细的文档。下面所有的都是基于Laravel 5.4.26,不同版本可能有异。
我不会在这里介绍DI/IoC的原理,如果对依赖注入与控制反转不是很熟悉,你可以阅读这篇文章 What is Dependency Injection?