问题描述
因此,我一直在尝试使用Javascript创建一个插件,并允许我的用户在甚至按Submit之前就可以看到该插件。这是我的Javascript代码:
function slugify(text) {
return text
.toString() // Cast to string
.toLowerCase() // Convert the string to lowercase letters
.normalize('NFD') // The normalize() method returns the Unicode normalization Form of a given string.
.trim() // Remove whitespace from both sides of a string
.replace(/\s+/g,'-') // Replace spaces with -
.replace(/[^\w\-]+/g,'') // Remove all non-word chars
.replace(/\-\-+/g,'-'); // Replace multiple - with single -
}
function listingslug(text) {
document.getElementById("slug").value = slugify(text);
}
这是我正在使用的HTML,它正在使用Bootstrap 4:
<form class="form">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" onkeyup="listingslug(this)" id="name" name="name" placeholder="Example input placeholder">
</div>
<label for="slug">Your vanity URL</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon3">{{ env('APP_URL') }}/listing/</span>
</div>
<input type="text" class="form-control" id="slug" name="slug" aria-describedby="basic-addon3">
</div>
</form>
我收到一个错误消息,表明listingslug不存在。我正在使用Laravel mix来编译我的代码。我在做什么错了?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)