Easiest way is to just allocate it based on time in each state.
So if 5/12's lived in first state, then take 5/12's of dividends and capital gains for first and remainder to second state.
Keep records in your tax file as how and why it was allocated this way. Make sure the total allocated does not exceed 100%.