我试图为现代浏览器找到一个合适的SVG库.我的目标是决定,什么库适合创建简单的在线SVG编辑器,例如.文本和路径编辑和剪切文本与路径.
我发现两个库,其可以是合适的:Snap.svg和Svg.js.
SNAP.SVG
Github:https://github.com/adobe-webplatform/Snap.svg
源代码行:6925 Github Stars:3445
Doc:http://snapsvg.io/docs/
入门:http://snapsvg.io/start /
Starter示例(JSBIN)
var draw = Snap(800, 600);
// create image
var image = draw.image('/images/shade.jpg',
0, -150, 600, 600);
// create text
var text = draw.text(0,120, 'SNAP.SVG');
text.attr({
fontFamily: 'Source Sans Pro',
fontSize: 120,
textAnchor: 'left'
});
// clip image with text
image.attr('clip-path', text);
Run Code Online (Sandbox Code Playgroud)
SVG.JS
Github:https://github.com/svgdotjs/svg.js
源代码行:3604 Github Stars:1905
Doc:https://svgdotjs.github.io/
入门示例(JSBIN): …
我的组件中有一些如下所示的代码。
<svg id="SvgjsSvg3254" width="318" height="152" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" class="apexcharts-svg" xmlns:data="ApexChartsNS" transform="translate(0, 0)" style="background: transparent none repeat scroll 0% 0%;">
Run Code Online (Sandbox Code Playgroud)
我收到如下错误
Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can turn on the 'throwIfNamespace' flag to bypass this warning.
Run Code Online (Sandbox Code Playgroud)
如何打开“throwIfNamespace”标志?
当我想在MySQL查询中定义自定义排序顺序时,我可以这样做:
ORDER BY FIELD(language,'USD','EUR','JPN')
Run Code Online (Sandbox Code Playgroud)
那个雄辩的ORM版本是什么?
更新:
这是解决方案,它也适用于各种领域的订购:
$events = Event::with( 'type', 'location' )
->orderBy( 'event_type_id' )
->orderByRaw( "FIELD(status, 'good', 'bad', 'hidden', 'active', 'cancelled')" )
->orderBy( 'date' );
Run Code Online (Sandbox Code Playgroud) 我刚刚在 Ubuntu 18.04 上安装了 MariaDB 10.1.29。从命令行我可以使用 sudo 连接:
sudo mysql -u root -p
Run Code Online (Sandbox Code Playgroud)
但并非没有 sudo。
另外,如果我尝试通过DBeaver连接到数据库,我会得到:
Could not connect: Access denied for user 'root'@'localhost'
Run Code Online (Sandbox Code Playgroud)
虽然凭据是正确的。我尝试安装 MySQL 5.7,但我也遇到了完全相同的问题。
我错过了什么?
我将 Eloquent 与 Slim Framework 结合使用来构建一个小型 API。出于某种原因,我收到此错误,但找不到问题所在:
Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.
数据库设置正确。此错误是在我的服务器暂存环境中引发的。在本地,使用 MySQL 5.6.29,它可以完美运行。虽然我认为它与 MySQL 5.7 无关,因为我在同一台服务器上运行了另一个应用程序,使用相同版本的 Eloquent。
任何人都可以指出我正确的方向吗?
我正在使用:
回溯
/path/to/app/shared/vendor/illuminate/container/Container.php:644
Illuminate\Container\Container -> make
/path/to/app/shared/vendor/illuminate/database/Connectors/ConnectionFactory.php:130
call_user_func
/path/to/app/shared/vendor/illuminate/database/Connection.php:964
Illuminate\Database\Connection -> getPdo
/path/to/app/shared/vendor/illuminate/database/Connection.php:832
Illuminate\Database\Connection -> reconnectIfMissingConnection
/path/to/app/shared/vendor/illuminate/database/Connection.php:717
Illuminate\Database\Connection -> run
/path/to/app/shared/vendor/illuminate/database/Connection.php:350
Illuminate\Database\Connection -> select
/path/to/app/shared/vendor/illuminate/database/Query/Builder.php:1648
Illuminate\Database\Query\Builder -> runSelect
/path/to/app/shared/vendor/illuminate/database/Query/Builder.php:1634
Illuminate\Database\Query\Builder -> get
/path/to/app/shared/vendor/illuminate/database/Eloquent/Builder.php:632
Illuminate\Database\Eloquent\Builder -> getModels
/path/to/app/shared/vendor/illuminate/database/Eloquent/Builder.php:327
Illuminate\Database\Eloquent\Builder -> get
/path/to/app/shared/vendor/illuminate/database/Eloquent/Builder.php:297
Illuminate\Database\Eloquent\Builder -> first
...
Run Code Online (Sandbox Code Playgroud)
我怀疑它与未注册的错误处理程序有关:
但是在不使用 Laravel 时如何注册自定义错误处理程序?
更新 @patricus 的解决方案可以实现如下: …
假设我有一个包含三个子类的基类。基类有一个大多数子类通用的方法,它有一个别名:
class Beer
def bottle_content
'250 ml'
end
alias_method :to_s, :bottle_content
end
class Heineken < Beer
end
class Stella < Beer
end
class Duvel < Beer
def bottle_content
'330 ml'
end
end
Run Code Online (Sandbox Code Playgroud)
现在,如果to_s在 的发散子类实例上调用该方法Duvel,250 ml则返回而不是330 ml。
我明白为什么;别名是在超类级别创建的。而且我知道这可以通过alias_method在发散类中重新定义 来解决。但是还有其他方法可以做到这一点吗?
显然,使用方法 forto_s会起作用:
class Beer
def bottle_content
'250 ml'
end
def to_s; bottle_content; end
end
Run Code Online (Sandbox Code Playgroud)
但也许有更优雅的方法?
我有一个带有 SVG 元素的组件,我试图将该 SVG 的各个部分分成不同的组件。嵌套组件需要从父组件动态创建,这是因为我正在从 json 文件构建整个 SVG 图形,该文件确定需要添加哪些嵌套组件(SVG 嵌套形状)。
为了动态创建组件,我使用 ComponentFactoryResolver 和 @angular/core 中的 ViewContainerRef
@Component({
selector: 'skick-player',
templateUrl: './player.component.html',
styleUrls: ['./player.component.scss'],
})
export class PlayerComponent implements OnInit, AfterViewInit {
@ViewChild('svgContainer', { read: ViewContainerRef }) container;
constructor( private resolver: ComponentFactoryResolver) {}
performFrame() {
....
//Add nested component
const factory = this.resolver.resolveComponentFactory(
BackDropItemComponent
);
const componentRef = this.container.createComponent(factory);
componentRef.instance.imagePath = objectUrl;
}
}
});
Run Code Online (Sandbox Code Playgroud)
}
问题是 Angular 将嵌套组件包裹在 div 中:
<div _nghost-qon-c42="" skick-back-drop-item="" class="ng-star-inserted">
Run Code Online (Sandbox Code Playgroud)
因此,由于创建了特殊的元素标签,它不会被渲染。如果删除该 div 元素,它将正确渲染嵌套的 SVG。
我知道我可以将嵌套组件渲染为指令并且它会起作用,如下所示:
<svg> …Run Code Online (Sandbox Code Playgroud) 在浏览 Yesod Book 的示例时,我遇到了以下代码片段的问题:
\n{-# LANGUAGE OverloadedStrings #-}\n{-# LANGUAGE QuasiQuotes #-}\n{-# LANGUAGE TemplateHaskell #-}\n{-# LANGUAGE TypeFamilies #-}\n{-# LANGUAGE ViewPatterns #-}\nimport Data.Text (Text)\nimport qualified Data.Text as T\nimport Yesod\n\ndata App = App\ninstance Yesod App\n\nmkYesod "App" [parseRoutes|\n/person/#Text PersonR GET\n/year/#Integer/month/#Text/day/#Int DateR\n/wiki/*Texts WikiR GET\n|]\n\ngetPersonR :: Text -> Handler Html\ngetPersonR name = defaultLayout [whamlet|<h1>Hello #{name}!|]\n\nhandleDateR :: Integer -> Text -> Int -> Handler Text -- text/plain\nhandleDateR year month day =\n return $\n T.concat [month, " ", T.pack $ show day, ", ", T.pack $ show …Run Code Online (Sandbox Code Playgroud)