由于性能限制,我正在尝试为v-model.lazy
模拟v-text-field
。
我尝试过:
<v-text-field :value="p.name" @change="v => p.name = v" :data-vv-name="'name'+p.id" v-validate="'required|max:255'" :error-messages="errors.collect('form'+p.id+'.'+'name'+p.id)" :counter="255" :label="$t('property.name')" required maxlength="255" :data-vv-as="' '" v-else></v-text-field>
如果我将输入与v-model.lazy一起使用,它会按预期工作,但是我无法使用v-text-field实现相同的功能。
这些事件是否应该使用prevent.default?
答案 0 :(得分:0)
添加private FusedLocationProviderClient mFusedLocationProviderClient;
private void getDeviceLocation() {
mFusedLocationProviderClient =
LocationServices.getFusedLocationProviderClient(this);
try {
if ( ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED ) {
return;
}
} catch (Exception e) {
e.printStackTrace();
}
final Task location = mFusedLocationProviderClient.getLastLocation();
Log.d("Works to here:","here");
location.addOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if ( task.isSuccessful() ) {
Location currentLocation = (Location) task.getResult();
double lat = currentLocation.getLatitude();
double lon = currentLocation.getLongitude();
Log.d("workes to here:",String.valueOf(lat));
addMarker(lat, lon);
final LatLng sydney = new LatLng(lat, lon);
mapFragment.mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
googleMap.addMarker(new MarkerOptions().position(sydney));
}
});
}
}
});
}
和data-vv-delay="1000"
而不是:value="p.name" @change="v => p.name = v"
可以大大改善延迟。这将延迟该字段的验证。
真正的解决方案需要v-model
才能在Vuetify的v-model.lazy
上运行,但情况并非如此。