我正在使用sweet-alert插件来显示警报.使用经典配置(默认值),一切正常.但是当我想在TEXT中添加HTML标签时,它会显示<b>...</b>而不会使其变为粗体.在搜索答案后,看起来我没有正确的搜索词......
如何使用HTML代码制作甜蜜警报显示文本?
var hh = "<b>test</b>";
swal({
title: "" + txt + "",
text: "Testno sporocilo za objekt " + hh + "",
confirmButtonText: "V redu",
allowOutsideClick: "true"
});
Run Code Online (Sandbox Code Playgroud) 我正在通过Anthony Viponds Youtube教程学习CodeIgniter .在创建和注册以及登录系统时,我已完成课程,但遇到了一些问题.我可以注册哪些可以在DB中看到.因此,出于测试目的,我使用用户名'test'和密码'test'创建了一个帐户,该帐户在MD5哈希中作为098f6bcd4621d373cade4e832627b4f6存储在数据库中.使用在线描述服务有效地存储和解密散列.所以没有类似修剪的问题.

当我尝试登录并将内容发布到validate方法时,我收到了索引页面,这意味着num_rows方法返回0而不是1表示有效登录.
membership_model.php
function validate() {
$this->db->where('username', $this->input->post('username'));
$this->db->where('password', md5($this->input->post('password')));
$query = $this->db->get('users');
print_r($this->db->queries);
if($query->num_rows == 1) {
return true;
}
else {
echo "Wrong";
}
}
Run Code Online (Sandbox Code Playgroud)
的login.php
function validate_credentials() {
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if ($query) {
$data = array(
'username' => $this->input->post('username'),
'is_logged_in' => true
);
echo 'here #1';
$this->session->set_userdata($data);
redirect('site/members_area');
}
else
{
$this->index();
}
}
Run Code Online (Sandbox Code Playgroud)
如你所见,我也做了一个'here#1'回声,这表明我达到了这一点.但正如我所提到的,它将我重定向到索引,这意味着else在login.php中执行.
所以很明显来自membership_model的validate()没有返回任何TRUE.
我用了
print_r($this->db->queries);
Run Code Online (Sandbox Code Playgroud)
查看输出和实际的SQL查询.
所以输出返回了查询.
SELECT * FROM `users` WHERE `username` = 'test' AND `password` …Run Code Online (Sandbox Code Playgroud) 我正在使用 Laravel 5.2。所以我正在学习如何处理角色和权限Authorization。一切都运行良好。我什至制定了自己的政策 PostPolicy。
现在解决问题了。我将 $post 数据加载到 PostsController 中的视图中,然后加载到 Blade 中。
帖子控制器:
public function show($id)
{
$post = Post::find($id);
return view('posts.show', compact('post'));
}
Run Code Online (Sandbox Code Playgroud)
帖子/show.blade.php:
@section('content')
<!-- begin -->
@can('hasRole', Auth::user())
<h1>Displaying Admin content</h1>
@endcan
@can('hasRole', Auth::user())
<h1>Displaying moderator content</h1>
@endcan
@can('hasRole', Auth::user())
<h1>Displaying guest content</h1>
@endcan
Run Code Online (Sandbox Code Playgroud)
政策:
public function hasRole($user)
{
// just for test
return true;
}
Run Code Online (Sandbox Code Playgroud)
现在返回所有内容。
当我将 Auth::user() 更改 @can('hasRole', Auth::user())
为字符串时,即
@can('hasRole', 'guest')
<h1>Displaying guest content</h1>
@endcan
Run Code Online (Sandbox Code Playgroud)
在这种情况下,它不会返回任何内容。由于我是 Laravel 的新手,我真的不知道它不起作用。