我有以下隐藏的输入:
<input id="PostId" type="hidden" value="1" name="PostId" >
Run Code Online (Sandbox Code Playgroud)
我想使用jquery检查值,以便我可以重定向到另一个页面,但我收到错误:
TypeError: "#PostId".val is not a function
Run Code Online (Sandbox Code Playgroud)
这是我的Jquery代码:
if (("#PostId").val() == 7 || ("#PostId").val() == 8) {
window.location = baseUrl + "Post/Details/" + ("#PostId").val();
}
Run Code Online (Sandbox Code Playgroud)
什么是正确的语法?
我有以下内容,但出现错误Cannot read property 'push' of undefined:
var vm = new Vue({
el: '#root',
data: {
posts: [],
newPost: {}
},
createPost: function() {
axios.post("api/posts/create", this.newPost).then(function (response) {
this.posts.push(response.data);
})
}
});
Run Code Online (Sandbox Code Playgroud)
在 Chrome 开发工具的网络选项卡中,我可以看到 response.data 显然是一个对象:
{
"id": 131,
"postContent": "<p>test</p>\n",
}
Run Code Online (Sandbox Code Playgroud)
那么为什么我会收到此错误?
我已经升级到Laravel 5.8
根据5.8中的文档所做的更改之一是,不推荐使用所有array_ *和str_ *全局帮助器(https://laravel.com/docs/5.8/upgrade#string-and-array-helpers)
在我的刀片视图中,我具有以下内容:
{{ (Arr::has($queryString, 'industry') ? Arr::get($queryString, 'industry') : '') }}
Run Code Online (Sandbox Code Playgroud)
这引发错误:
Class 'Arr' not found...
Run Code Online (Sandbox Code Playgroud)
如果我包含全名空间,则可以使用:
{{(Illuminate \ Support \ Arr :: has($ queryString,'industry')?Illuminate \ Support \ Arr :: get($ queryString,'industry'):'')}}
请指教。
条带文档说,当使用自动确认的付款意图时,您应该使用 webhook 异步完成客户的订单。
如果我提供一项服务,例如购买后下载文件的能力,那么为什么我需要监控网络payment_intent.succeeded钩子?
如果在以下handleCardPayment功能中付款成功,那么是否还有可能会失败?如果付款成功,为什么我不应该允许用户立即下载文件?
var cardholderName = document.getElementById('cardholder-name');
var cardButton = document.getElementById('card-button');
var clientSecret = cardButton.dataset.secret;
cardButton.addEventListener('click', function(ev) {
stripe.handleCardPayment(
clientSecret, cardElement, {
payment_method_data: {
billing_details: {name: cardholderName.value}
}
}
).then(function(result) {
if (result.error) {
// Display error.message in your UI.
} else {
// The payment has succeeded. Display a success message.
}
});
});
Run Code Online (Sandbox Code Playgroud)
也许我还没有理解 handleCardPayment 是如何工作的。任何帮助表示赞赏。
我在控制器中定义了一个laravel列表,如下所示:
$industries = Industry::lists('id', 'name');
$salaries = Salary::lists('id', 'range', 'rate');
Run Code Online (Sandbox Code Playgroud)
如何输出或访问刀片模板中的列?
我做了以下操作,我收到错误'试图获取非对象的属性':
@foreach ($industries as $industry)
<div class="checkbox margin-top-0 ">
<label>
{!! Form::checkbox('industry_list[]', $industry->id) !!}
{{$industry->name}}
</label>
</div>
@endforeach
Run Code Online (Sandbox Code Playgroud)
如何迭代使用for循环以及我正在尝试确定第一次迭代 - 使用下面的我得到偏移错误.
@for ($i = 0; $i <= count($salaries); $i++)
<div class="checkbox @if($i == 0) margin-top-0 @endif ">
<label>
{!! Form::checkbox('salary_list[]', $salaries->id) !!}
{{$salaries->name}}
</label>
</div>
@endfor
Run Code Online (Sandbox Code Playgroud)
我如何迭代$ salaries数组 - 我是否需要使它成为一个集合,因为Salary::lists('id', 'range', 'rate');数组只包含两列而奇怪的是当我做'dd($ salaries);`为什么数组定义为'range'值为key和'id'作为值,尽管它被声明为'id'是关键?
array:33 [
"10,000 - 15,000" => 24
"15,000 - 20,000" => 25
]
Run Code Online (Sandbox Code Playgroud) 我有以下jquery函数,但它在if语句上抛出一个错误: TypeError: elem.nodeName is undefined
当我在if语句之外输出console.log时它工作正常吗?
<input type="radio" name="contact" value="email">email
<input type="radio" name="contact" value="tel">tel
<input type="radio" name="contact" value="writing">writing
$(function() {
var myListRef = {'email':'email','tel':'tel','writing':'writing'}
$('[name="contact"]').click(function() {
$.each( myListRef , function( key, value ) {
if(value !== $(this).val()) {
console.log($(this).val());
}
});
});
});
Run Code Online (Sandbox Code Playgroud)
我在if语句中做错了什么?
我有以下数组:
$days = [
['dow' => 1, 'day' => 'Monday'],
['dow' => 2, 'day' => 'Tuesday'],
['dow' => 3, 'day' => 'Wednesday'],
['dow' => 4, 'day' => 'Thursday'],
['dow' => 5, 'day' => 'Friday'],
['dow' => 6, 'day' => 'Saturday'],
['dow' => 7, 'day' => 'Sunday'],
];
Run Code Online (Sandbox Code Playgroud)
我试图在我的刀片模板中循环遍历它,如下所示:
@foreach ($days as $day)
<label>{{$day['day']}}</label>
{!! Form::text('day_of_wk[$day['dow']].start_time', null, ['class' => 'form-control'])!!}
@endforeach
Run Code Online (Sandbox Code Playgroud)
但我得到错误: syntax error, unexpected 'dow' (T_STRING)
如何$day['dow']在 day_of_wk[] 输入数组中添加值?
我有一个班级,在每种方法中我都会反复声明以下几行:
var viewsPath = Path.GetFullPath(HostingEnvironment.MapPath(@"~/Views/Emails"));
var engines = new ViewEngineCollection();
engines.Add(new FileSystemRazorViewEngine(viewsPath));
Run Code Online (Sandbox Code Playgroud)
如何以及在何处声明它们以便每个方法都可以使用它以便我不必在每个方法中重复写入相同的行?
public class EmailService
{
public EmailService()
{
}
public void NotifyNewComment(int id)
{
var viewsPath = Path.GetFullPath(HostingEnvironment.MapPath(@"~/Views/Emails"));
var engines = new ViewEngineCollection();
engines.Add(new FileSystemRazorViewEngine(viewsPath));
var email = new NotificationEmail
{
To = "yourmail@example.com",
Comment = comment.Text
};
email.Send();
}
public void NotifyUpdatedComment(int id)
{
var viewsPath = Path.GetFullPath(HostingEnvironment.MapPath(@"~/Views/Emails"));
var engines = new ViewEngineCollection();
engines.Add(new FileSystemRazorViewEngine(viewsPath));
var email = new NotificationEmail
{
To = "yourmail@example.com",
Comment = comment.Text …Run Code Online (Sandbox Code Playgroud) 我有以下html,我想用带有空格的下划线替换所有出现在带有类的div内的锚标签 xyz
<div class="xyz">
<b><a>Hello_1</a></b>
</div>
<div class="xyz">
<b><a>Hello_2</a></b>
</div>
Run Code Online (Sandbox Code Playgroud)
以下不起作用?
$('.xyz').each(function() {
var $this = $(this);
$this.find('a').text().replace(/_/g, ' '));
});
Run Code Online (Sandbox Code Playgroud) 什么是去除所有的HTML标签和那里有正则表达式<br>和 <p>标签更换一个单一的空间,并删除所有换行符?
例如:
<h1>Heading</h1>
<br>
<br />
<a href="#">hyperlink</a>
<p></p>
<p>paragraph1</p>
<p>paragraph2</p>
Run Code Online (Sandbox Code Playgroud)
应该变成:
Heading hyperlink paragraph1 paragraph2
Run Code Online (Sandbox Code Playgroud)
我尝试了以下方法:
$string = preg_replace( ["/<br\s*\/?>/i","/<\/p\s*>/i"]," ",$string);
$string = preg_replace(["/<\/?[^>]+>/", "/\r?\n|\r/"],"",$string);
Run Code Online (Sandbox Code Playgroud)
这给了我:
Heading hyperlink paragraph1 paragraph2
Run Code Online (Sandbox Code Playgroud)
任何实际可行的单行或更优雅的解决方案的想法?
我有以下数据库表,其中主题和评论之间的关系是 1:N
Category
id
name
Topic
id
title
category_id
Comment
id
details
topic_id
deleted (boolean)
Run Code Online (Sandbox Code Playgroud)
我想要一个查询来计算每个类别中的评论总数。我有以下 LINQ 查询,但它不起作用:
@foreach (var cat in Model.AllPermissionSets.Keys)
{
var commentCount = cat.Topics.Where(c => c.Comments.deleted != 0).SelectMany(x => x.Comments).Count();
@* some other stuff *@
}
Run Code Online (Sandbox Code Playgroud)
在 Visual Studio 中我收到错误IList<Comment> doesn not contain a definition for deleted...
执行上述操作的正确语法是什么?
我有以下表格:
<form>
<input type="radio" name="foo" value="1" checked="checked" />
<input type="radio" name="foo" value="0" />
<input name="this" value="xxx" />
<select name="bar">
<option value="hi" selected="selected">Hi</option>
<option value="ho">Ho</option>
</select>
<a class="js-add" href="#" >Add</a>
</form>
Run Code Online (Sandbox Code Playgroud)
我有以下函数,它在单击添加链接时传递整个表单:
$(".js-add").click(function (e) {
e.preventDefault();
values = getFormValues($("form"));
});
getFormValues = function($form) {
var bar = $form.bar.val();
}
Run Code Online (Sandbox Code Playgroud)
如何从表单对象中检索特定的输入值。因此,例如在上面的getFormValues函数中,我想获取条形输入字段的值,但上面的方法不起作用。通常我会这样做:$bar.val();但是我如何从表单对象中获得相同的结果?
javascript ×4
jquery ×4
arrays ×3
php ×3
regex ×2
blade ×1
c# ×1
file ×1
for-loop ×1
html ×1
json ×1
laravel ×1
laravel-5 ×1
laravel-5.1 ×1
laravel-5.8 ×1
linq ×1
linq-to-sql ×1
oop ×1
powershell ×1
preg-replace ×1
scope ×1
variables ×1
vue.js ×1
vuejs2 ×1
webhooks ×1