我有一个div电话呢#container,在这里#container我有n大量的img标签叫它images
n可以是2,10,40等等.我想知道我怎么能适应n的量images内#container关闭所有空格stretch图像.质量无所谓这是我到现在为止所尝试的:
var amount = $("#container > img").length;
var amount_w = amount*200; //200 width of 1 image
var amount_h = amount*130; //120 height image
var refH = $("#container").height();
var refW = $("#container").width();
var refRatio = refW/refH;
$("#container img").each(function(){
$(this).height((amount_h-130)-refH);
$(this).width((amount_w-230)-refW);
});
Run Code Online (Sandbox Code Playgroud) 我期待验证一些文件名.但无法弄清楚正确的正则表达式文件名可以是任何东西,但需要检查文件名是否以
所以档案
my_file_dummy_name.jpeg - not valid
my_file_dummy_name_en.jpeg - valid
Run Code Online (Sandbox Code Playgroud)
对于现在我尝试了这个(并且正在工作,但也许有更好的解决方案)
/(\_\w.\.\w+)/g
Run Code Online (Sandbox Code Playgroud)
多一个:
/(\_[a-z]{2}\.[a-z]{3,4})/g
Run Code Online (Sandbox Code Playgroud) 我遇到了从数据库中选择的问题。基本上我想要实现的是:我有一个包含 3 列的表格
type | number | date
Run Code Online (Sandbox Code Playgroud)
我需要根据列(类型)做 where
If(type = 1) then where number > 1 else where date today()
Run Code Online (Sandbox Code Playgroud)
因此,如果 type 等于 1,则应用到 number 的位置,否则应用到 date 的位置。有可能这样做吗?用 Laravel Eloquent 可以做到吗?谢谢你。
原始查询和数据类型是:
type = string
number = integer
date = timestamp (Y-m-d H:i:s)
询问
SELECT * FROM table_name
WHERE CASE WHEN type=days THEN date>now() ELSE number>0 END
表架构
CREATE TABLE banners (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
type varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
number int(10) …
我有以下问题,我需要配置Nginx,所以在任何URL用户访问时,它将保留uri(示例domain.com/some/url/),但只传递给laravel /并让Angular处理路由.
Route::get('/', function(){
return view('index');
});
Run Code Online (Sandbox Code Playgroud)
当访问/api/{anything}Laravel时会启动.
现在我index.html从公共文件夹返回,直到找到解决方案这是我的配置:
location / {
index index.html;
try_files $uri $uri/ /index.html;
}
location /api {
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以做一条路线:
Route::get('{anything?}', function(){
return view('index');
});
Run Code Online (Sandbox Code Playgroud)
但是要广泛.
更新:
location / {
rewrite ^/(.*)$ / break;
index index.php;
try_files $uri $uri/ /index.php;
}
location /api {
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
Run Code Online (Sandbox Code Playgroud) 我有一个列秒表,我在其中插入在线时间(以秒为单位),
Carbon::parse($seconds)->forHumans();
Run Code Online (Sandbox Code Playgroud)
不允许我这样做,有没有办法解析秒并将其传输给人类阅读?像 1 小时还是 2 周?
我的CSS:
#a_x200{
visibility: hidden;
width: 200px;
height: 200px;
background-color: black;
}
Run Code Online (Sandbox Code Playgroud)
我的JS:
<script type="text/javascript">
function show(id) {
document.getElementById(id).style.display = 'block';
}
</script>
Run Code Online (Sandbox Code Playgroud)
我的Html
<div id="a_x200">asd</div>
<innput type="button" class="button_p_1" onclick="show('a_x200');"></input>
Run Code Online (Sandbox Code Playgroud)
不工作我想我错过了什么!
我有一个问题,关于如何验证IP:端口在一起.例:
192.158.2.10:80 < - 有效
192.158.2.10 <---无效
所以端口是必须的,我找到了一些IP验证(正则表达式),但要与端口合并没有运气.我不想为端口使用单独的输入字段.
我的想法是这样的:
var str = '192.168.10.2:80';
var substr = ':';
if (str.indexOf(substr) !== -1){
var pieces = str.split(':', 2);
var ip = pieces[0];
var port = pieces[1];
//and here validate ip and port
}else{
console.log('the char '+substr+' is not there');
}
Run Code Online (Sandbox Code Playgroud)
这是对的吗?还是更简单?
我正在研究Laravel Echo(使用socket.io作为连接器)
但是我找不到用户/访问者成功或未连接到套接字(非通道)时如何绑定回调的方法,但通常无法连接。
import Echo from "laravel-echo"; //import Laravel-echo
if(typeof(io) != 'undefined'){ //check if io loaded
//init Echo
window.Echo = new Echo({
broadcaster: 'socket.io',
host: { path: '/socket.io' }
});
}
Run Code Online (Sandbox Code Playgroud)
所以在这里我检查io是否存在,然后很可能套接字已启动。
但是我们可以像使用socket.io一样绑定回调吗:来自socket.io文档的示例
const socket = io('http://localhost');
console.log(socket.id); // undefined
socket.on('connect', () => {
console.log(socket.id); // 'here we can get socket id'
});
Run Code Online (Sandbox Code Playgroud)
我需要回调的原因是获取套接字ID并启动其他脚本。
我使用fullcalendar.io vue扩展。
我想挂钩事件渲染来添加操作,但事件回调仅包含 JS 元素。
有没有办法将vue组件注入其中?
<FullCalendar
ref="fullCalendar"
defaultView="dayGridMonth"
:firstDay="1"
:editable="true"
:draggable="true"
:timeZone="'UTC'"
:header="false"
:events="events"
:plugins="plugins"
@eventRender="eventRender"
/>
Run Code Online (Sandbox Code Playgroud)
JS
import FullCalendar from '@fullcalendar/vue'
import dayGridPlugin from '@fullcalendar/daygrid'
import interactionPlugin from '@fullcalendar/interaction';
export default {
components: {
FullCalendar
},
data () {
return {
loader: false,
calendar: null,
plugins: [
dayGridPlugin, interactionPlugin
],
events: [
{"id":1,"start":"2019-11-25","end":"2019-11-27"},
{"id":2,"start":"2019-11-23","end":"2019-11-26"},
{"id":3,"start":"2019-11-22","end":"2019-11-25"},
{"id":4,"start":"2019-11-21","end":"2019-11-24"}
]
}
},
mounted() {
this.calendar = this.$refs.fullCalendar.getApi();
},
methods:{
eventRender(info){
console.log(info);
},
}
}
Run Code Online (Sandbox Code Playgroud)
例如内部eventRender(这是所需内容的肮脏示例): …
我试图动画Bootstrap Carousel与animate.css
我finished with caption animation一切正常,但如何动画的item
HTML:
<div class="item zoomInLeft animated">
<img data-src="/images/1.jpg" alt="...">
<div class="carousel-caption">
<h1 data-animation="bounceInDown" data-delay="400">Lorem Ipsum</h1>
<h3 data-animation="bounceInDown" data-delay="600">Lorem Ipsum</h3>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
如果有人需要我的字幕代码(JS)
function carousel_init(c){
var self = this;
self.carouselAnimations = function (elems) {
elems.each(function (index) {
var el = $(this);
var animEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
var animation = el.data('animation')+' animated';
var delay = el.data('delay');
el.attr('style', '-webkit-animation-delay:'+delay+'ms; -moz-animation-delay:'+delay+'ms; -o-animation-delay:'+delay+'ms; animation-delay:'+delay+'ms')
.promise().done(function(){
el.addClass(animation).one(animEnd, function () {
el.removeClass(animation);
}); …Run Code Online (Sandbox Code Playgroud) javascript ×5
jquery ×5
php ×5
css ×3
laravel ×3
html ×2
laravel-5 ×2
regex ×2
angularjs ×1
animate.css ×1
animation ×1
eloquent ×1
fullcalendar ×1
image ×1
laravel-5.3 ×1
laravel-5.5 ×1
laravel-echo ×1
mysql ×1
nginx ×1
socket.io ×1
validation ×1
vue.js ×1
vuejs2 ×1
vuetify.js ×1