Fix List component constructor: ensure opts.options exists before accessing width/height properties

This commit is contained in:
yumoqing 2026-04-22 15:55:45 +08:00
parent fbd94e86a1
commit 3f449816ed

View File

@ -3,17 +3,22 @@
bricks.List = class extends bricks.VBox {
constructor(opts) {
// Ensure opts has options property
if (!opts) opts = {};
if (!opts.options) opts.options = {};
// Set default dimensions if not provided
if (!opts.options.width) opts.options.width = '100%';
if (!opts.options.height) opts.options.height = '100%';
super(opts);
this.data_url = opts.data_url || null;
this.items = opts.items || [];
this.item_template_url = opts.item_template_url || null; // URL to the item template .ui file
this.itemHeight = opts.itemHeight || 50;
this._loading = false;
// Set default dimensions
if (!this.options.width) this.options.width = '100%';
if (!this.options.height) this.options.height = '100%';
// Load data if provided
if (this.data_url) {
this.loadData();