我需要将此脚本从 js 更改为 ts 但我需要观察者的语法
export default {
props: ['branch_id'],
watch: {}
}
Run Code Online (Sandbox Code Playgroud) 我试图从数据库中名为usuario的表中获取id值,将$ username作为参数传递,函数$ conexion-> connect()返回一个mysqli对象.这些函数没有给我任何错误但它没有返回数据库中的值.我错过了什么吗?或者犯了什么错误.感谢帮助.
public function checkUserNameExists($username){
$conexion = new Connection();
$conexion->connect();
$query = "select id from usuario where username = ?";
$reg = 0;
$stmt= $conexion->connect()->prepare($query);
$stmt->bind_param('s',$username);
$stmt->execute();
$stmt->bind_result($id);
while($stmt->fetch()){
$reg = $id;
}
$stmt->close();
return $reg;
}
Run Code Online (Sandbox Code Playgroud)
这是函数connect()在类文件"Connection"中的位置
public function connect(){
$mysqli = new mysqli($this->db_host,$this->db_user,$this->db_pass,$this->db_name);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
return $mysqli
}
Run Code Online (Sandbox Code Playgroud) 我有一个 Vuetify 日期选择器:
<v-menu
v-model="menu1"
:close-on-content-click="false"
max-width="290"
>
<template v-slot:activator="{ on }">
<v-text-field
v-model="editedItem.Eintrittsdatum"
clearable
color="primary"
label="Eintrittsdatum"
v-on="on"
></v-text-field>
</template>
<v-date-picker
v-model="editedItem.Eintrittsdatum"
@change="menu1 = false"
locale="de"
></v-date-picker>
</v-menu>
Run Code Online (Sandbox Code Playgroud)
返回值是正常格式的日期 (yyyy-mm-dd)。这也是我想保存在 v-model 中的数据(并最终保存在数据对象中)。但是,只是为了吸引眼球,我想以不同的格式显示文本字段的值。
我创建了一个小函数:
formatDate(date) {
return date ? moment(date).format("L") : "";
}
Run Code Online (Sandbox Code Playgroud)
有没有办法调用这个函数来覆盖显示的值?
我试图显示一个基于 url 的搜索框,意味着对于特定路线,它将显示搜索框,否则不会显示。为此我使用了Request::path()
. 但问题是对于某些路线它不起作用。假设我有两条路线,例如
Route::get('products','abcontroller@index');
Route::get('product/{name}','abcontroller@searchProduct');
Run Code Online (Sandbox Code Playgroud)
现在如果我使用以下代码:
@if(Request::path() == 'products' || Request::path() == 'product/{name}')
// something print
@endif
Run Code Online (Sandbox Code Playgroud)
对于products
路线,我可以看到搜索框,但product/{name}
我看不到..我该如何解决这个问题?