mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2024-11-20 10:39:59 +01:00
feat: basic use of custom components
This commit is contained in:
parent
f102928812
commit
b96bdf25f6
@ -0,0 +1,5 @@
|
||||
<div class="checkbox-wrapper" @click="check">
|
||||
<div :class="{ checkbox: true, checked: checked }"></div>
|
||||
<div class="title">{{ title }}</div>
|
||||
<q-btn color="primary">XXX</q-btn>
|
||||
</div>
|
@ -0,0 +1,18 @@
|
||||
async function initMyCheckbox(path) {
|
||||
const t = await loadTemplateAsync(path)
|
||||
Vue.component('my-checkbox', {
|
||||
name:'my-checkbox',
|
||||
template: t,
|
||||
data() {
|
||||
return { checked: false, title: 'Check me' }
|
||||
},
|
||||
methods: {
|
||||
check() {
|
||||
this.checked = !this.checked;
|
||||
console.log('### checked', this.checked)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -139,3 +139,23 @@ const readFromSerialPort = serial => {
|
||||
}
|
||||
return readStringUntil
|
||||
}
|
||||
|
||||
function loadTemplateAsync(path) {
|
||||
const result = new Promise(resolve => {
|
||||
const xhttp = new XMLHttpRequest()
|
||||
console.log('### 300')
|
||||
|
||||
xhttp.onreadystatechange = function () {
|
||||
if (this.readyState == 4) {
|
||||
if (this.status == 200) resolve(this.responseText)
|
||||
|
||||
if (this.status == 404) resolve('Page not found.')
|
||||
}
|
||||
}
|
||||
|
||||
xhttp.open('GET', path, true)
|
||||
xhttp.send()
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
@ -31,7 +31,9 @@
|
||||
</q-btn>
|
||||
</div>
|
||||
|
||||
<div class="col-auto q-pr-lg"></div>
|
||||
<div class="col-auto q-pr-lg">
|
||||
<my-checkbox></my-checkbox>
|
||||
</div>
|
||||
<div class="col-auto q-pl-lg">
|
||||
<q-input
|
||||
borderless
|
||||
@ -1710,5 +1712,6 @@
|
||||
<script src="{{ url_for('watchonly_static', path='js/tables.js') }}"></script>
|
||||
<script src="{{ url_for('watchonly_static', path='js/map.js') }}"></script>
|
||||
<script src="{{ url_for('watchonly_static', path='js/utils.js') }}"></script>
|
||||
<script src="{{ url_for('watchonly_static', path='js/components/my-checkbox/my-checkbox.js') }}"></script>
|
||||
<script src="{{ url_for('watchonly_static', path='js/index.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user