我使用 VueJS 2,我真的不知道如何从子组件到父组件进行通信。
我有 2 个组件:Dashboad和DashboardPanel。
在DashboardPanel中,我有一种方法:
execute () {
// emit to parent
this.$emit('executeSQL', this.value)
...
}
Run Code Online (Sandbox Code Playgroud)
在仪表板中:
mounted () {
// get event from DashboardPanel
this.$on('executeSQL', function(value) {
alert(value)
})
}
Run Code Online (Sandbox Code Playgroud)
什么也没发生,我在文档中找不到在哪里使用$on并且我不知道是否可以使用其他方式来实现它?
I use Symfony 4.1, and I try a simple usage of form builder :
$builder
->add('name', TextType::class)
->add('phone', TelType::class)
->add('password', RepeatedType::class, array(
'type' => PasswordType::class,
'invalid_message' => 'Passwords don\'t match',
'options' => array('attr' => array('class' => 'password-field')),
'required' => false,
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Password confirmation'),
'mapped' => false,
))
Run Code Online (Sandbox Code Playgroud)
I got the error :
The option "invalid_message" does not exist. Defined options are ....
I don't find any informations on it, I just tried …
我使用这个插件:https : //github.com/autoNumeric/autoNumeric
我使用这个初始化:
AutoNumeric.multiple('.autonumeric-number', AutoNumericConfigDecimal);
AutoNumeric.multiple('.autonumeric-integer', AutoNumeric.getPredefinedOptions().integerPos);
Run Code Online (Sandbox Code Playgroud)
然后,我有一个 Ajax 调用,我需要设置输入的新值。问题是:我无法使用.set()插件的方法,因为它需要在初始化后获得一个变量。
因为我使用了多个选择器,所以我不能有这个变量。
现在,我尝试再次初始化:
// element already has mask
<input id="element" class="autonumeric-integer" />
// after ajax call
var element = new AutoNumeric('#element', AutoNumericConfig);
element.set(value);
Run Code Online (Sandbox Code Playgroud)
但它加倍了我在输入中写的内容,“2”变成了“22”。
是否可以仅使用 DOM 元素使用 AutoNumeric 函数?而不是初始化后得到的变量?
namespace App\Http\Controllers;
use Auth;
use Illuminate\Http\Request;
class maincontroller extends Controller
{
public function home(Request $request)
{
if(Auth::Attempt($request->only('email','password'))) {
return redirect('/');
}
}
}
Run Code Online (Sandbox Code Playgroud)