Data Properties
Define reactive properties for your UI Wires with just a few lines of code.
Similar to Vue.js and other frontend JavaScript frameworks, you can define reactive properties on your Wires.
Defining Properties
You can define and initialize properties on your Wires using data
.
Data Properties are parsed and tracked by Livewire and JavaScript, therefore only data types that are castable to JavaScript can be stored in Data Properties (strings, numeric, arrays, structs, or booleans). If you are needing more complex data types for your templates, use Computed Properties instead.
When data properties are mutated, the UI will update also.
Accessing Properties
Data Variable
You can reference a property using data.[propertyName]
.
Getters
Getter methods are automatically available for your properties based on the property's name. You to access the property within your Wire using this.get[propertyName]()
.
You can use this as an alternative to using data
.
Templates
You can reference data properties within your Wire's template using args.[propertyName]
.
Resetting Properties
You can reset properties back to their original value using reset()
.
There are several ways to use reset.
Security
Your component's private variables
scope will hold your data property definitions and current values, but it's necessary to be cautious about what you store.
The values of your data properties are included with each XHR response and Livewire uses these values to determine what should be updated in the DOM.
You should NEVER store sensitive data ( such as passwords, and SSNs ) that you wouldn't want your application's users to see.
Last updated