我需要在我的代码中使用这个滑块插件" 光滑 "但无法实现它!
define('modules/slider', ['jquery', 'slick'], function($, slick) {
var widgetDisplay = function() {};
widgetDisplay.prototype = {
name: 'Display',
init: function(scope) {
"use strict";
var me = this;
console.log('slider module loaded + ' + slick);
}
};
return widgetDisplay;
});
Run Code Online (Sandbox Code Playgroud)
在配置中,我有;
require.config({
baseUrl: '<?php echo WPF__ASSETS; ?>scripts/',
paths: {
"modernizr": "<?php echo WPF__ASSETS; ?>scripts/modernizr",
"jquery": "<?php echo WPF__ASSETS; ?>scripts/jquery",
"fastclick": "<?php echo WPF__ASSETS; ?>scripts/fastclick",
"foundation": "<?php echo WPF__ASSETS; ?>scripts/foundation",
"slick": "<?php echo WPF__ASSETS; ?>scripts/slick"
},
shim: {
'foundation': {
deps: …Run Code Online (Sandbox Code Playgroud) 如何在我的 require.js 应用程序中包含/使用此 require.js 模块PSD.js?
如果我使用如下例所示的脚本,它会按预期工作:
<script type="text/javascript" src="assets/scripts/vendor/psd.min.js"></script>
<script type="text/javascript">
(function () {
var PSD = require('psd');
document.getElementById('dropzone').addEventListener('dragover', onDragOver, true);
document.getElementById('dropzone').addEventListener('drop', onDrop, true);
function onDragOver(e) {
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
}
function onDrop(e) {
e.stopPropagation();
e.preventDefault();
PSD.fromEvent(e).then(function (psd) {
var data = JSON.stringify(psd.tree().export(), undefined, 2);
document.getElementById('data').innerHTML = data;
document.getElementById('image').appendChild(psd.image.toPng());
});
}
}());
</script>
Run Code Online (Sandbox Code Playgroud)
这是一个活生生的例子; https://jsfiddle.net/numediaweb/8zah99jw/
但是,如果我尝试通过执行推荐的 requirejs 方式来包含它,则不会;
requirejs.config({
paths: {
'psd': 'vendor/psd.min'
}
});
// Load our app module 'main.js' and pass it to our …Run Code Online (Sandbox Code Playgroud) 我有一台 vagrant 机器,其 IP 地址如下:
Vagrant.configure("2") do |config|
config.vm.network :private_network, ip: 192.168.33.11
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.hostname = "my-devenv"
...
end
Run Code Online (Sandbox Code Playgroud)
一切都很好。但我对虚拟机上的 /etc/hosts 文件感到困惑:使用 localhost 和虚拟机的 IP(127.0.0.1 some-dev-site.dev vs 192.168.33.11 some-dev-site.dev)有什么区别?
127.0.0.1 localhost
127.0.0.1 some-dev-site.dev
192.168.33.11 some-dev-site.dev
Run Code Online (Sandbox Code Playgroud) 正如你在下面的图片中看到的,我有一些返回的json data有三个对象; 每个包含客户端id =>数据.

exact_match : {104}
match_4 : {104, 103}
match_2 : {104, 103, 68}
Run Code Online (Sandbox Code Playgroud)
如何根据之前的"修剪"或删除重复的对象?就像是:
exact_match : {104}
match_4 : {103}
match_2 : {68}
Run Code Online (Sandbox Code Playgroud)
我尝试了_.difference但没有工作(也许是因为它是数组而不是对象?):
var exact_match = data.exact_match,
match_four_digits = _.difference(data.match_4, data.exact_match),
match_two_digits = _.difference(data.match_2, data.exact_match, data.match_4),
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激 :)
更新
我需要返回的值具有相同的对象数据而不是新的数组:)
在mysql docker hub 页面中,有关于如何创建用户的参考:
MYSQL_USER, MYSQL_PASSWORD
Run Code Online (Sandbox Code Playgroud)
但是如何在 docker-compose.yml 文件中指定这些参数呢?
到目前为止,我有:
mysql:
image: mysql:5.7
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: R00t+
Run Code Online (Sandbox Code Playgroud)
另一个问题; 如何从容器外部连接到 mysql 主机?在容器内,我可以使用以下方法进行连接:
$user = 'root';
$pass = 'R00t+';
$server = 'mysql';
$dbh = new PDO( "mysql:host=$server", $user, $pass );
Run Code Online (Sandbox Code Playgroud) 在Vagrant设置中,我使用Ansible来配置虚拟机.
在其中一个Ansible角色中,我有一个复制文件~/bin/夹内部文件的任务:
~/bin/one.sh
~/bin/two.sh
我想创建这些文件的符号链接,以便最终结果如下:
~/bin/one.sh
~/bin/two.sh
~/bin/one (符号链接到~/bin/one.sh)
~/bin/two(符号链接到~/bin/two.sh)
我怎样才能做到这一点?到目前为止,我已经尝试了这个,但它不起作用:
- name: Common tasks =>Create symlinks for utilities
file: src=~/bin/{{ item }} dest=~/bin/ mode=755 state=link
with_fileglob:
- bin/*
Run Code Online (Sandbox Code Playgroud)
我需要在里面加一个带有dest=~/bin/文件名的正则表达式(比如one.sh)并删除扩展名(one.sh变成one)但是我不知道该怎么做.
更新
我终于使用了这个任务:
- name: Copy common files to ~/bin
copy: src={{ item }} dest=~/bin/ mode=755
with_fileglob:
- bin/*
- name: Ensure symlinks for utilities exist
file: src=~/bin/{{ item | basename | regex_replace('(\w+(?:\.\w+)*$)', '\1') }} dest=~/bin/{{ …Run Code Online (Sandbox Code Playgroud) 正如您在Angularjs常见问题解答中所读到的那样,$rootScope不鼓励使用.因此,服务更适合存储稍后将在控制器之间共享的数据.但是我无法在ng-show不使用的情况下使指令工作$rootScope.
这就是我正在做的事情;
的index.html
<div ng-controller="GlobalCtrl">
<div ng-show="showSettings"></div>
<aside ng-show="showSettings" >
<h1>Some text</h1>
<button ng-click="closeSettings()">Ok</button>
</aside>
</div>
Run Code Online (Sandbox Code Playgroud)
app.js (我正在开发应用程序,因为我正在开发cordova ..代码被截断)
var app = angular.module('tibibt', ['tibibt.controllers', 'tibibt.filters', 'tibibt.services']);
angular.element(document).ready(function () {
angular.bootstrap(document, ['tibibt']);
});
Run Code Online (Sandbox Code Playgroud)
services.js
/* Create an application module that holds all services */
var tibibtServicess = angular.module('tibibt.services', []);
/* Global service */
tibibtServicess.service('globalService', function () {
this.Data = {
showSettings: 'false'
};
this.getAll = function () {
return this.Data;
}; …Run Code Online (Sandbox Code Playgroud) Symfony 文档没有给出Symfony 中工厂使用的完整示例。
就我而言,我有许多不同的服务,可以生成不同的水果 API:
每个服务都有自己的依赖项,依赖项是一些绑定参数:
services:
_defaults:
autowire: true
bind:
$guzzleClientBanana: '@eight_points_guzzle.client.banana'
$guzzleClientApple: '@eight_points_guzzle.client.apple'
...
Run Code Online (Sandbox Code Playgroud)
服务举例:
# BananaApiService.php
class BananaApiService extends DefaultEndpointService
{
protected $guzzleClientBanana;
public function __construct(GuzzleClient $guzzleClientBanana)
{
$this->guzzleClientBanana = $guzzleClientBanana;
}
public function handleRequest(ApiRequest $apiRequest)
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
目前我没有使用工厂模式,而是将所有服务传递给管理器的构造函数,这太脏了并且不符合最佳实践:
# ApisManagerService
class ApisManagerService
{
protected $BananaApiService;
protected $AppleApiService;
protected $PearApiService;
public function __construct(BananaApiService $BananaApiService,
AppleApiService $AppleApiService,
PearApiService $PearApiService)
{
$this->BananaApiService = $BananaApiService;
//...
}
public function requestDispatcher(ShoppingList $shoppingList): void …Run Code Online (Sandbox Code Playgroud) 我有一个由拉丁语和柏柏尔字符串组成的多维数组,我想用它作为替换输入数据的参考:
var alphabet = Array ( Array( 'a', '?' ), Array( 'b', '?' ), Array( 'g', '?' ), Array( 'gw', '??' ), Array( 'd', '?' ), Array( '?', '?' ), Array( 'e', '?' ), Array( 'f', '?' ), Array( 'k', '?' ), Array( 'kw', '??' ), Array( 'h', '?' ), Array( '?', '?' ), Array( '?', '?' ), Array( 'x', '?' ), Array( 'q', '?' ), Array( 'i', '?' ), Array( 'j', '?' ), Array( 'l', '?' ), Array( 'm', …Run Code Online (Sandbox Code Playgroud) 谁能解释一下我wp_localize_script()做了什么?即使我在WP Codex中读到它,我也不明白它的作用.
我在Angularjs中使用的服务指令不是工厂,我需要将json文件填充到局部变量;
/* Contains projects on the town */
leMaireServicess.service('cityService', function($http) {
// JSON regions and cities loader
this.cities = [];
// initCities
this.initCities = function() {
this.cities = $http.get('data/census/cities.js').success(function(data) {
return data;
});
return this.cities;
};
// Get city info
this.getCity = function() {
return this.cities;
};
});
Run Code Online (Sandbox Code Playgroud)
在我的控制器中我有
// Saved game controller
leMaireControllers.controller('GameCoreCtrl', function($scope, cityService) {
/* Control the town project slides */
cityService.initCities();
$scope.city = cityService.getCity();
console.log($scope.city);
});
Run Code Online (Sandbox Code Playgroud)
但它没有返回实际数据,而是返回;
Object {then: function, catch: function, finally: function, …Run Code Online (Sandbox Code Playgroud)